Your third attempt is correct - but what is happening to guess_row before/after this code? For example, consider the following:

a = "Hello"
try:
    a = int(input("Enter a number: "))
except ValueError:
    print("Not an integer value...")
print(str(a))

If you enter a valid number, the final line will print out the value you entered. If not, an exception will be raised (showing the error message in the except block) and a will remain unchanged, so the final line will print "Hello" instead.

You can refine this so that an invalid number will prompt the user to re-enter the value:

a = None
while a is None:
    try:
        a = int(input("Enter a number: "))
    except ValueError:
        print("Not an integer value...")
print(str(a))
Answer from user4200092 on Stack Overflow
🌐
Real Python
realpython.com › python-input-integer
How to Read Python Input as Integers – Real Python
March 18, 2026 - In this tutorial, you’ll learn how to create a reusable utility function that’ll guarantee valid integer inputs from an interactive user. Along the way, you’ll learn about Python’s tools for getting a string from the console and converting that string into an integer.
Discussions

Is there a way to make input() accept strings and integers?
Instead of casting input straight into an integer you can wait and check if it's done first. Instead of: grade = int(input("Enter grade: ")) Do this: grade = input("Enter grade: ") if grade.lower() == 'done': print("Done.") else: integer_grade = int(grade) More on reddit.com
🌐 r/learnpython
6
3
October 8, 2021
python - How can I read inputs as numbers? - Stack Overflow
Why are x and y strings instead of ints in the below code? (Note: in Python 2.x use raw_input(). In Python 3.x use input(). raw_input() was renamed to input() in Python 3.x) play = True while pl More on stackoverflow.com
🌐 stackoverflow.com
How to make users only enter integer values in Python program - Stack Overflow
Let the user enter anything he wishes, and warn only if it wasn't an integer: try: num = int(input("enter number: ")) except ValueError: print("you must enter an integer") This is the Pythonic way to do it, after all it's "Easier to ask forgiveness than permission". More on stackoverflow.com
🌐 stackoverflow.com
python - why does "int" come before "input"? I would like to understand the logic of this code - Stack Overflow
The prompt "Enter an integer: " is shown, clearly indicating the desired type of input. Next, the input is converted into an integer using the int() function. This important step guarantees that the value entered by the user is treated as a whole number, making it suitable for mathematical ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
W3Schools
w3schools.com › python › python_user_input.asp
Python User Input
The input from the user is treated as a string. Even if, in the example above, you can input a number, the Python interpreter will still treat it as a string.
🌐
Hyperskill
hyperskill.org › university › python › input-and-input-in-python
Python input() Function: Get User Input with Examples
June 5, 2026 - When you use the input() function ... typing '123' is seen as the string '123'. On the hand for integer input you need to change the string input into an integer using the int() function....
🌐
Tutorial Teacher
tutorialsteacher.com › articles › convert-input-to-number-in-python
Convert Input to Number in Python
So, always use the input() function in Python 2.x. Example: Convert User Input to Int in Python 2 Copy
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-take-integer-input-in-python
How to take integer input in Python? - GeeksforGeeks
April 3, 2026 - n = int(input("Enter the size of list: ")) lst = list(map(int, input( "Enter the integer elements of list(Space-Separated): ").strip().split()))[:n] print('The list is:', lst)
Find elsewhere
🌐
Bobby Hadz
bobbyhadz.com › blog › python-only-allow-integer-user-input
How to take Integer user input in Python | bobbyhadz
Use the input() function to take input from the user. Use a try/except statement to make sure the input value is an integer.
🌐
GeeksforGeeks
geeksforgeeks.org › python › taking-input-in-python
Taking Input in Python - GeeksforGeeks
... You can optionally provide ... by default. If you need another data type (like integer or float), you must convert it manually using typecasting....
Published: May 29, 2026
🌐
Pierian Training
pieriantraining.com › home › python tutorial: how to take an integer input in python
Python Tutorial: How to take an integer input in Python - Pierian Training
April 12, 2023 - In the above code, we first use the `input()` function to read the user input as a string. We then use the `int()` function to convert the string to an integer and store it in a variable called `num`. Finally, we print out the value of `num` ...
🌐
PYnative
pynative.com › home › python › python input: take input from user
Python Input(): Take Input From User [Guide]
February 23, 2024 - # program to calculate addition of two input integer numbers # convert inout into int first_number = int(input("Enter first number ")) second_number = int(input("Enter second number ")) print("\n") print("First Number:", first_number) print("Second Number:", second_number) sum1 = first_number + second_number print("Addition of two number is: ", sum1)Code language: Python (python) Run ... Enter first number 28 Enter second number 12 First Number: 28 Second Number: 12 Addition of two number is: 40 · Note: As you can see, we explicitly added a cast of an integer type to an input function to convert an input value to the integer type. Now if you print the type of first_number you should get integer type. type(first_number ) will return <class 'int'> Same as integer, we need to convert user input to the float number using the float() function
🌐
TutorialsPoint
tutorialspoint.com › how-to-take-integer-input-in-python
How to take integer input in Python?
August 28, 2023 - import sys # Convert command line arguments to integers if len(sys.argv) > 1: numbers = [int(arg) for arg in sys.argv[1:]] print("Command line integers:", numbers) print("Sum:", sum(numbers)) print("Average:", sum(numbers) / len(numbers)) else: print("No arguments provided") # Run as: python script.py 10 20 30 40 · Command line integers: [10, 20, 30, 40] Sum: 100 Average: 25.0 · Always handle cases where input might not be a valid integer ?
🌐
IncludeHelp
includehelp.com › python › read-input-as-an-integer.aspx
How to take integer input in Python?
There is no such method, that can be used to take input as an integer directly – but input string can be converted into an integer by using int() function which accepts a string and returns an integer value.
🌐
BeginnersBook
beginnersbook.com › 2018 › 01 › python-get-user-input
Getting Input from User in Python
# Python Program - Get Integer Input from User num = int(input("Enter an Integer: ")) print(num)
🌐
Stack Overflow
stackoverflow.com › questions › 20449427 › how-can-i-read-inputs-as-numbers
python - How can I read inputs as numbers? - Stack Overflow
Why are x and y strings instead of ints in the below code? (Note: in Python 2.x use raw_input(). In Python 3.x use input(). raw_input() was renamed to input() in Python 3.x) play = True while pl...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-input-function
Python input() Function - GeeksforGeeks
By default, input() always returns data as a string, even if you enter numbers. If you want other types like integer (int) or floating-point (float), you have to convert (typecast) the value explicitly.
Published: September 18, 2025
🌐
Stack Abuse
stackabuse.com › bytes › how-to-read-python-input-as-number
How To Read Python Input As Number
July 22, 2022 - All we did is to wrap the usual input() function in the int() constructor. Running this command will prompt us with the message "Enter a number:". After the user inputs a number, input() will read it as a string, and the int() will convert that string to a base-10 integer.
Top answer
1 of 5
7
integer_number = int(input("something here"))

is just an abbreviated way of saying:

temp_var = input("something here")
integer_number = int(temp_var)

It is not the other way around, because the int() function takes a string and converts it into an int. If you did it the other way around, the function wouldn't have anything to convert.

2 of 5
2

In Python you can pass functions as arguments of another function and of course they'll be evaluated before the outer function. Guess I should point you to the relevant official Python documentation that states that, but just googling for it isn't working right now.

See Python’s Functions Are First-Class:

Python's functions are first-class objects. You can assign them to variables, store them in data structures, pass them as arguments to other functions, and even return them as values from other functions.

Got a nice answer about that on SO :

What are "first-class" objects:

In short, it means there are no restrictions on the object's use. It's the same as any other object.

A first class object is an entity that can be dynamically created, destroyed, passed to a function, returned as a value, and have all the rights as other variables in the programming language have.

Your one is not the first question about that:

All arguments are evaluated before the function is called:

Answer:

You are right, all arguments are evaluated before the function is called, otherwise the function cannot know what is passed to it. So what you are doing is actually:

but no link to docs here too.

Took a while, I found it here:

6.3.4. Calls its the link for Python 3:

...............All argument expressions are evaluated before the call is attempted. Please refer to section Function definitions for the syntax of formal parameter lists.........