+ 1
Doubt on input
I am confused It takes the input as a string, but what if my calculations use numbers so how do I take the input in numbers? PLZZZ HELP
4 odpowiedzi
+ 2
For example:
number = int(raw_input())
or you can define your inputs in the code as an int():
number1 = input()
number2 = input()
result = int(number1) + int(number2)
print result
I hope you take the answer
+ 1
number=int(input("please enter the first number"))
number2=int(input("please enter the second number"))
sum = number+ number2
print("the sum of your numbers is : %s." % (sum))
you get the input as string, convert them in integer, and print out the result as string.
i hope it helps.
0
thx
0
Well ! that solution only works if you are on Python 2 (which you shouldn't use) because of raw_input() and the print statement. The solution in Python 3 (which you SHOULD use) is int(input()), raises ValueError if it is not an int
Hope it helped