このコードを変更する方法を理解するのに苦労しています。入力値をランダムな整数と比較する前に整数に変換する代わりに、ランダムな整数を文字列に変換してから比較を行います (文字列を文字列と比較します)。私はプログラミングの初心者です。また、私が求めている答えは欲しくありません。それをよりよく理解する方法と、どこから始めるべきかだけです。これは人々にとって簡単に思えるかもしれませんが、私は苦労しています。
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))