4 Respuestas
+ 16
https://code.sololearn.com/csi052Mqkwhd/?ref=app
This is my code in python 3.
+ 4
No I'm talking about IDE on PC
+ 3
I believe you need something like this:
from random import randint
rand = randint(0, 10)
for Trials in range(3):
if int(input('Please guess the number:')) == rand:
print(' Great, You Got It.')
break
else:
print(' Wrong, Try Again.') if Trials < 2 else print(' Game Over.')
+ 3
I found more efficient code than it:
from time import sleep
from random import randint
from os import system
while True:
i = 0
num = randint(0,30)
x = 0
while i <= 4:
i += 1
guess = int(input("Enter you guess(0-30)."))
if guess == num:
print("You have guess well in {} attempts.".format(i))
x = 1
break
elif guess <= num:
print("Your guess is low.")
print("Try again.")
elif guess >= num:
print("Your guess is high.")
print("Try again.")
if x == 0:
print("You have ran out of 5 attempts.")
print("Correct answer is {}".format(num))
choise = input("Do you want to try again.(y/n)")
if choise == "y":
pass
else:
exit()