This is happening because input
returns you a str
, not an int
, which is what you're after. You can fix this by casting the str
into an int
as follows:
a = int(input('Enter number for factorial operation: '))
Take a look at this:
In [68]: a = input('Enter number for factorial operation: ')
Enter number for factorial operation: 5
In [69]: a
Out[69]: '5'
In [70]: type(a)
Out[70]: str
In [71]: isinstance(a, str)
Out[71]: True
In [72]: isinstance(a, int)
Out[72]: False
In [73]: a = int(input('Enter number for factorial operation: '))
Enter number for factorial operation: 5
In [74]: a
Out[74]: 5
In [75]: type(a)
Out[75]: int
In [76]: isinstance(a, str)
Out[76]: False
In [77]: isinstance(a, int)
Out[77]: True