0
Can I have help?
Hi guys I need help with something, how do I pick how many tries the player gets?
9 odpowiedzi
+ 1
i am new to coding on python
+ 1
you could add a counter and display it on the screen. please provide your code if you need further help
0
Ok can you write down the code to do plz?
0
print ('hello world')
print ('I am a computer')
print ('can you guess my number?')
print ('the number is between 1 and 99')
print ('lets start now')
import random
n = random.randint(1, 99)
guess = int(raw_input("Enter an integer from 1 to 99: "))
tries=10
while n != "guess":
print
if guess < n:
print "your guess is too low"
guess = int(raw_input("Enter an integer from 1 to 99: "))
elif guess > n:
print "your guess is too high"
guess = int(raw_input("Enter an integer from 1 to 99: "))
else:
print "you guessed it!"
break
print
0
its a simple code
0
im just new so im not that good
0
print ('hello world')
print ('I am a computer')
print ('can you guess my number?')
print ('the number is between 1 and 99')
print ('lets start now')
import random
n = random.randint(1, 99)
tries=10
for i in range(tries):
guess = int(input())
if guess < n:
print("your guess is too low")
elif guess > n:
print(“your guess is too high")
else:
print ("you guessed it!")
break
These are the changes I would make. Note that a guessing game of this kind won’t work in the code playground as all inputs need to be given before the code is run.
- 1
they are working together good so far so both, but I need help how to make a number of tries the player gets