0
Help!!! Why my code is not run in sololearn but normally in Pycharm
Traceback (most recent call last): File "./Playground/file0.py", line 10, in <module> guess_number = int(number_input) ValueError: invalid literal for int() with base 10: ''
3 odpowiedzi
+ 3
Can you share your code?
0
Here!!!
import random
number_secret = random.randint(1, 20)
exit_choice = ""
while exit_choice != "no":
number_of_guess = 1
list_guess = []
number_input = input("Guessing a secret number(from 1 to 20):\n")
guess_number = int(number_input)
list_guess.append(guess_number)
while guess_number != number_secret:
if guess_number in range(1, 21):
if guess_number < number_secret:
print(guess_number, "is less than a secret number!!")
else:
print(guess_number, "is greater than a secret number!!")
print("You guessed", number_of_guess, "time(s)")
print("Your guessed list", list_guess)
print("-" * 50)
number_input = input("Retype another number:\n")
guess_number = int(number_input)
number_of_guess += 1
list_guess.append(guess_number)
list_guess.sort()
else:
print(guess_number, "is out of range from 1 t0 20")
print("You guessed", number_of_guess, "time(s)")
print("Your guessed list", list_guess)
print("-" * 50)
number_input = input("Please guessing another number in range from 1 to 20:\n")
guess_number = int(number_input)
number_of_guess += 1
list_guess.append(guess_number)
list_guess.sort()
print("Congratulations!", guess_number, "is secret number")
print("You have to guess", number_of_guess, "time(s)")
print("Your guessed list", list_guess)
print("-" * 50)
exit_choice = input("Do you wanna re-play the game (yes or no):\n")
print("The game is over!! Thank you for playing")
0
ok. thank you.