0

Can I have help?

Hi guys I need help with something, how do I pick how many tries the player gets?

9th Mar 2019, 6:23 PM
Aiden
Aiden - avatar
9 Answers
+ 1
i am new to coding on python
9th Mar 2019, 6:23 PM
Aiden
Aiden - avatar
+ 1
you could add a counter and display it on the screen. please provide your code if you need further help
9th Mar 2019, 6:48 PM
Mau
Mau - avatar
0
Ok can you write down the code to do plz?
9th Mar 2019, 6:49 PM
Aiden
Aiden - avatar
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
9th Mar 2019, 6:49 PM
Aiden
Aiden - avatar
0
its a simple code
9th Mar 2019, 6:49 PM
Aiden
Aiden - avatar
0
im just new so im not that good
9th Mar 2019, 6:50 PM
Aiden
Aiden - avatar
0
Aiden The first half of your code is Python 3. The second half is Python 2. Which one are you planning to use?
9th Mar 2019, 7:00 PM
Diego
Diego - avatar
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.
10th Mar 2019, 12:13 AM
Russ
Russ - avatar
- 1
they are working together good so far so both, but I need help how to make a number of tries the player gets
9th Mar 2019, 7:02 PM
Aiden
Aiden - avatar