When I resolve the indentation errors the while loop goes into an infinite loop, not moving on to the next section of code. In the output this happens. How can I fix these errors and make the code still work? import random #this allows randomiser functions such as generating both the player and computers number to work.
play = True
print("Hello! Welcome to 13 in - to Win")
name = input("What is your name? ")
while play == True:
#print("The game starts here")
AI_num = random.randint(1,19) #Generate a Random Number between 1 and 19 for the computer.
Additional_Num = True
PTotal = 0
while Additional_Num == True:
Player_Num = random.randint(1,10)
PTotal = PTotal + Player_Num
print(name,"Got A",Player_Num)
print("Your Total is: ",PTotal) #Later add an input statement to ask user if they want to know their total
play_again = input("Would You Like Another Number? <Yes or No>")
if play_again == "Yes":
Additional_Num = True
else:
Additional_Num = False
#Game Ends here
print("AI got ",AI_num)
print(name,"Got ",PTotal)
#Check for the Winner
if PTotal > AI_num:
print("The AI was no match for ", name)
else:
if PTotal == AI_num:
print("Well this is anticlimactic, it's a Draw!")
else:
print(name,"was no match for the AI")
#print("13 in to Win Has Ended!")
play_again = input("Would you like to play again? <Yes or No>")
if play_again == "Yes":
play = True
else:
play = False
print("Bye for now!")