I fixed up my code and it is working so far
But, at the end I intended it to repeat the round with the same cards and add up the total
if(Select > AINumber):
print("You won! Your card was higher than the AI's card", "Your card was", Select, "AI's card was", AINumber)
print("You scored", (Select - AINumber), "points!")
if(Select < AINumber):
print("You Lost! Your card was lower than the AI's card", "Your card was", Select, "AI's card was", AINumber)
print("AI scored", (AINumber - Select), "points!")
if(Select == AINumber):
print("You tied with the AI! Your card was the same as the AI's card", "Your card was", Select, "AI's card was", AINumber)
print("Nobody scored points!")
It didn't do either of these. I'm still working on the code what should i keep in mind when fixing the random.randint and very last lines and if there is a short cut to repeating the rounds or not.
def instructions():
print("You will be playing with an ai and whoever lays down the highest number wins that round.")
print("The points you get are determined by how much higher your card was from your opponents card.")
print("The person with the most points wins!")
def getUserInput():
print ("\nDo you want to play?: ")
print("\nChoices")
print("1. Yes")
print("2. No\n")
Choice = input()
if(Choice == 'Yes') or (Choice == 'yes'):
print("Okay, lets get started!")
startGame()
elif(Choice == 'No') or (Choice == 'no'):
print("Okay, bye!")
else:
print("That is not a Choice!")
print("Choose 'Yes' or 'No'")
getUserInput()
def startGame():
print("Round One!")
print("\nHere are your 9 cards.\n")
import random
My_Deck = []
for Cards in range(9):
Cards = random.randint(1, 100)
My_Deck.append(Cards)
while True:
print("Select one of your cards: "),
print(My_Deck)
Select = int(input())
try:
if (Select in My_Deck):
My_Deck.remove(Select)
print("You have selected", Select)
print("Your deck is now,")
print(My_Deck)
break
else:
print("You don't have that card in your deck!")
except ValueError as e:
print(e)
AINumber = random.randint(1, 100)
if(Select > AINumber):
print("You won! Your card was higher than the AI's card", "Your card was", Select, "AI's card was", AINumber)
print("You scored", (Select - AINumber), "points!")
if(Select < AINumber):
print("You Lost! Your card was lower than the AI's card", "Your card was", Select, "AI's card was", AINumber)
print("AI scored", (AINumber - Select), "points!")
if(Select == AINumber):
print("You tied with the AI! Your card was the same as the AI's card", "Your card was", Select, "AI's card was", AINumber)
print("Nobody scored points!")
instructions()
getUserInput()
startGame()
Aucun commentaire:
Enregistrer un commentaire