Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to convert python input to int

# Any input taken by python is always taken as a string.
# To convert it to an integer, we have to wrap input() in int(). Example:

num1 = int(input("Enter a number: "))
num2 = int(input("Enter another number: "))
total = num1 + num2
print(f'Sum: {total}')
 
PREVIOUS NEXT
Tagged: #convert #python #input #int
ADD COMMENT
Topic
Name
6+1 =