This is my second script in my first language so I'm trying to get oriented and better foundations. I noticed in the
while loop I got really messy but I couldn't google my way to a better solution that I could understand. With that, I'd appreciate any feedback that makes my code more "pythonic" or clean.
import random def card_deck(): card_faces = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace'] card_suits = ['♠', '♦', '♥', '♣'] deck =  for i in card_suits: for j in card_faces: deck.append(j + ' ' + i) return deck def card_draw(deck): random.shuffle(deck) deck = deck.pop() return deck def card_value(card): card = str(card) if card == 'J': return 10 elif card == 'Q': return 12 elif card == 'K': return 13 elif card == 'A': return 14 else: card = int(card[0:2]) return card correct_guesses = 0 deck = card_deck() card = card_draw(deck) while True: card_points = card_value(card) if not deck: print("You've done it! You've won with", correct_guesses, "correct guesses!") break next_card = card_draw(deck) next_card_points = card_value(next_card) print("\nYou're card is: ", card) user_guess = input('\n(H)igher, (L)ower, or (S)ame?:\t') user_guess = user_guess.lower() if user_guess not in ('h', 'l', 's'): break if card_points < next_card_points and user_guess == 'h': print("Correct!") correct_guesses += 1 card = next_card continue elif card_points > next_card_points and user_guess == 'l': print("Correct!") correct_guesses += 1 card = next_card continue elif card_points == next_card_points and user_guess == 's': print("Correct!") correct_guesses += 1 card = next_card continue else: print('You lose the next card was ', next_card) print('You had', correct_guesses, 'correct guesses.') break ```