0
Can we input something in a data type other than string in Python?? I cant seem to carry out arithmetic operation on input var.
4 Réponses
+ 1
thank you for explaining it so well 😃
0
Input something other than string?
x = int(input()) # integer input
y = int(input())
print("Sum = {}".format(x + y))
PS:
Prachi Pandit, if you want to input data that is not a string then, Yes, you will have to type-cast it!
Note that (x + y) is an integer. That is why, I used .format() to convert it to string 😉
0
so do we need to typecast it every time? in order to carry out operations?
0
and is it by default input in a string type?? and I can't understand why you included 'format' in your output