Everything is right, right?
TristanMisja (8)

All the syntax is fine, but it bugs out! Please tell me why and how to fix it!

You are viewing a single comment. View All
Answered by potootos (19) [earned 5 cycles]
View Answer
potootos (19)

I figured it out,
1st is that you wrote radaint on line 9, instead of randint
2nd you need to select all code included in the class game and press TAB and then SHIFT + TAB. How that will help you is that it will get rid of the indentation error the program was throwing. The case might be that you included some 'spaces' instead of 'tabs'.
3rd you need to put an int() statement in front of the input() statement on line 11 of the code because currently what the user inputs is a string, a string cannot be compared using the >, <, symbol because the code does not interpret it as a number. Using the int() statement like so: int(input('enter a number!: ')) will covert the string into an integer (number).
4th you clear the terminal too quickly, and therefore your function doesn't have time to print if the answer is too high or too low. You could fix by altering the time.sleep function to 6 seconds.


import random,sys,os,time
from colorama import Fore

def endFunc():

class Game:
def NumGuess():
x = random.randint(0,10)
while True:
y = int(input("Enter a number!: "))
if y == x:
elif y < x:
print("Too low!")
elif y > x:
print("Too high!")
print("Enter a valid number!")


potootos (19)

@TristanMisja if I answered your question please mark it answered so others will know :D

TristanMisja (8)

@potootos Thanks alot! It helped!

TristanMisja (8)

@potootos Repl.it is broken :/
Also, something else is wrong D:

TristanMisja (8)

@potootos it says the "try:" is invalid syntax