我很难理解如何更改此代码。我不想在将输入值与随机整数进行比较之前将其转换为整数,而是将随机整数转换为字符串,然后进行比较(将字符串与字符串进行比较)。我是编程初学者。另外,我不想要我问的答案,只是如何更好地理解它以及我应该从哪里开始。我很抱歉,这对人们来说似乎很容易,但我正在努力解决这个问题。
import random
#this function generates a random number between 1 and 100 and asks the user to guess the number
def playGame2():
number = random.randint(1,100)
guess = input("I'm thinking of a number between 1 and 100. Guess what it is: ")
if number == int(guess):
print("That is correct!")
else:
print("Nope...I was thinking of " + str(number))