Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # https://www.reddit.com/r/learnpython/comments/4zyg0h/encountering_a_problem_with_defining_a_variable/
- #
- # http://pastebin.com/0RvD5JJ3
- #
- dealer = input("Input a number for the dealer ")
- player = input("input a score for the player ")
- print "The dealer's score is", dealer, "and your score is", player, "."
- if dealer > 7:
- print "The dealer has a natural!"
- elif dealer > 5:
- print "The dealer does not deal himself a new card!"
- else: # now it has to be `dealer <= 5` so you don't need `elif/if`
- #deal the dealer a third card
- print "The dealer deals himself a third card!"
- third_card = input("input the dealer's third card: ")
- dealer = dealer + third_card
- dealer = dealer % 10
- # or in one line
- # dealer = (dealer + third_card) % 10
- if player > 7:
- print "You have a natural!"
- elif player > 5:
- print "You do not get dealt a third card!"
- else: # now it has to be `player <= 5` so you don't need `elif/if`
- #deal the player a third card
- third_card = input("input the player's third card: ")
- player = player + third_card
- player = player % 10
- print "You have been dealt a third card! Your card is", third_card, "! Your total value is now", player, "!"
- if player > dealer:
- print "You win! You have a final score of", player, "and the dealer had a score of", dealer, "!"
- elif player < dealer:
- print "The dealer wins! He had a score of", dealer, "and you had a score of", player, "!"
- else: # now it has to be `player == dealer` so you don't need `elif/if`
- print "It is a draw! Both players have a final value of", dealer, "!"
Add Comment
Please, Sign In to add comment