Created
December 30, 2019 20:44
-
-
Save calthoff/26f38d107785ea8858bfa4fb43bc8d91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Hi Juan! Overall, your code looks good. However, there is a way to change your program | |
| # using a data structure that will significantly shorten your program. Generally, when | |
| # you have a bunch of if-statements, you should think about ways to shorten your code | |
| # See if you can find a relationship between rock, papers, and scissors and use a | |
| # data structure to take advantage of that relationship and shorten your code | |
| import random | |
| print ("Let's play rock, paper, scissors") | |
| options = ["rock", 'paper',"scissors"] | |
| counter = 0 | |
| cpu_counter = 0 | |
| player_counter = 0 | |
| while counter <3: | |
| random_number = random.randint(0,2) | |
| CPU = options [random_number] | |
| #print("CPU choosed ", CPU ) | |
| player = input ("rock, paper or scissor? Type your option: ") | |
| print("You choosed " , player) | |
| if player == CPU: | |
| print("CPU choosed ", CPU ) | |
| print("Tie") | |
| counter -= 1 | |
| if player == "scissors": | |
| if CPU == "paper": | |
| print("CPU choosed ", CPU ) | |
| print("You Win =)") | |
| player_counter += 1 | |
| if CPU == "rock": | |
| print("CPU choosed ", CPU ) | |
| print("You loose :( ") | |
| cpu_counter += 1 | |
| if player == "paper" : | |
| if CPU == "rock" : | |
| print("CPU choosed ", CPU ) | |
| print("You Win =)") | |
| player_counter += 1 | |
| if CPU == "scissors" : | |
| print("CPU choosed ", CPU ) | |
| print ("You loose :(") | |
| cpu_counter += 1 | |
| if player == "rock" : | |
| if CPU == "scissors" : | |
| print("CPU choosed ", CPU ) | |
| print("You Win =)") | |
| player_counter += 1 | |
| if CPU == "paper" : | |
| print("CPU choosed ", CPU ) | |
| print ("You loose :(") | |
| cpu_counter += 1 | |
| counter += 1 | |
| if counter == 3: | |
| if cpu_counter > player_counter: | |
| print("CPU : ", cpu_counter) | |
| print("YOU: ", player_counter) | |
| print("CPU is the winner!") | |
| if player_counter > cpu_counter: | |
| print("CPU : ", cpu_counter) | |
| print("YOU: ", player_counter) | |
| print("YOU are the winner =)") | |
| print("Game Over :(") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment