When I try to compare two integers I am getting an int error. Saying that it can't compare an int and a string but I am casting the input(string) to an int. Can someone explain why this happened?
I tried to int cast userInput = int(input(PROMPT) then I returned userInput. Then I try to compare my computerChoice to userInput and am getting an error.
def userInput():
userInput = int(input(PROMPT))
return userInput
Here is entire code: Python3 btw:
PROMPT = "Please enter an integer: "
WELCOME = "THE GUESSING GAME"
#get input
def userInput():
userInput = int(input(PROMPT))
return userInput
#get computer guess
def computerGuess():
import random
computerGuess = (int)(random.random()*6)
return computerGuess
def game(userInput, computerInput):
while userInput != computerInput:
print("Try again")
userInput()
if userInput == computerInput:
print("You win!!")
def main():
#get user Input in main
theInput = userInput()
#computer input
computer = computerGuess()
#launch game
game(theInput, computer)
main()