Last answered:

29 Nov 2023

Posted on:

25 May 2021

1

guess = int(guess). Not clear about the usage of this statement

If we have already used

if guess.isdigit()

then why are we using,

guess = int(guess)

Digit is already an integer then why are we converting it

3 answers ( 0 marked as helpful)
Posted on:

04 Nov 2021

1

Python String isdigit() method is a built-in method used for string handling. The isdigit() method returns “True” if all characters in the string are digits, Otherwise, It returns “False”. 

Posted on:

04 Nov 2022

0

why we use guess = int (guess) ?  still not understand this .

Posted on:

29 Nov 2023

0

guess=int(guess) is used to convert the input (which is initially a string) into an integer.


When you use the input() function in Python, it captures user input as a string by default. However, since you're comparing the user's guess to the secret_number variable (which is an integer), you need to convert the user's input from a string to an integer using the int() function.

Submit an answer