+ 1
Can anyone help me with this code pleas
Guess the number game: I want to add to the code how many times it took to guess the number. Like: Welldone, you guessed it in 7 times.
6 Respuestas
+ 3
Buzi Chaban ,
The code you pasted in your comment has no indentations.
Assuming you fix the indentations, you'll need these three lines. I'll let you figure out where to put each one.
guesstimes = 0
guesstimes += 1
print("Well done. You guessed it in", guesstimes, "guesses.")
+ 7
You just need to add an ordinary counter to the loop that will add 1 each time the loop is executed and output the result under a positive condition...😎
+ 6
Buzi Chaban ,
additionally (to the already mentioned issues) the following ones also has to be fixed: (line counting includes empty lines)
line 3: declaration / initilization requires a value
line 6: closing parenthesis missing
line 6, 9, 11, 13: wrong kind of quotes around the strings
+ 2
thankyou for the help guys I got it
import random
te_raden = random.randint(1,100)
guesstimes = 1
while True:
number = int(input(“Guess the number: “)
if(number != te_raden):
guesstimes += 1
if(number > te_raden):
print(“To high”)
elif(number < te_raden):
print(“to low”)
elif(number == te_raden):
print(“you guessed the number”)
break
+ 1
Buzi Chaban , forgot to write the counter output...😎
0
#this is what I have so far
import random
te_raden = random.randint(1,100)
guesstimes =
while True:
number = int(input(‘Guess the number: ‘)
if(number > te_raden):
print(‘To high’)
elif(number < te_raden):
print(‘to low’)
elif(number == te_raden):
print(‘you guessed the number’)
break