+ 1
Code error
import random numbers = [1,2,3,4,5,6,7,8,9,10] x = random.randint(0, 10) guess = int(input ("Choose a number between 1 and 10: ")) if guess < 0 print ("Too low!") if guess > 10 print ("Too high!") if guess == x print ("You won!") else: print ("You lost.") # Thanks guys! check out my game: https://code.sololearn.com/cEhCVol8Owx8/#py
4 Antworten
+ 4
: missing after if statements.
+ 5
You forgot to end line 10 with a colon 😉
0
# In addition to Meharban Singh
# First, why did you declared
numbers = [1,2,3,4,5,6,7,9,10]
# Second, why did you included 0 in
x = random.randint(0,10)
# Third, not an error, but the probability of winning is only 10%, why so low ??😲
0
To RahulVerma,
This is a simple American game, in which one guesses a number the operator had chosen.
The 0 inside the random number picker is a starting point, and is not included in the range.
The percentage of winning is rather reasonable. Have you ever been to a casino?