I've created a basic addition statement, i am aware that input is being read as a string but my code prints out "none" before taking an input (see below). How do i take integer as an input??
# code example
print("This is a calculator")
a = input(print("Enter the first number"))
b = input(print("Enter the second number"))
print("sum =", a + b)
This outputs:
This is a calculator
Enter the first number
None5
Enter the second number
None6
sum = 56
remove print()
in the first two lines:
a = input("Enter the first number")
b = input("Enter the second number")
instead of:
a = input(print("Enter the first number"))
b = input(print("Enter the second number"))
None
is the return of the print()
function so since input()
prints what you input to it you are printing the returned None
value. Then the print statement will still print the prompt. However you want to let input()
print the prompt as described above.