Multiple input() on the code playground | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Multiple input() on the code playground

Hi everybody, ¿How can I get multiple inputs in the code playgroung without getting a traceback? This is the code: """ Haz un juego que genera un número aleatorio del 1 al 100 y se trata de que lo adivines. El juego te pide que introduzcas números y te indica si el número introducido es mayor o menor que el número que hay que adivinar. Tienes 7 intentos, si no, el programa se termina y te dice que has perdido. """ import random x = random.randint(1,100) intentos = 0 max_intentos = 7 while intentos < max_intentos: guess = int(input("Te quedan:"+str(max_intentos - intentos)+" intentos."+" Prueba suerte:")) if x == guess: print("Congratulations") break elif x > guess: print("Mas alto") intentos += 1 else: print("Mas bajo") intentos += 1 else: print("Lo siento, has perdido, el resutado era: " + str(x)) Thanks.

11th Mar 2021, 10:06 PM
Goyo Dominguez
Goyo Dominguez - avatar
3 Answers
+ 1
Well since playground isn't interactive you need to provide all inputs first time only , each new input on a newline.
11th Mar 2021, 10:24 PM
Abhay
Abhay - avatar
0
Pero puedes hacer lo seguiente. Tu puder requerer los "inputs" en la mesma liña. Por exemplo.: x,y,z=input().split(" ") >>3 10 5 print(x) >>3 print(y) >>10 print(z) >>5
11th Mar 2021, 11:16 PM
▲TopGun ▲
▲TopGun ▲ - avatar
0
Ok thank you!!
12th Mar 2021, 8:26 AM
Goyo Dominguez
Goyo Dominguez - avatar