num=int(input(''enter the values'')) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

num=int(input(''enter the values''))

Why we are wrote int(input) why we can't write only input

15th Aug 2023, 8:52 AM
Laxmi
Laxmi - avatar
3 Answers
+ 8
Laxmi Already explained in you previous question. I think question has been deleted. BTW.... The Main difference is in the data type of the input. This "int(input())" converts the user input into an integer. while this "input()" treats the input as a string. It depends on what you want to do with the user input.. #if you want to perform mathematical operations on the input, you would use "int(input())". And #If you just need the input as a string, then "input()" is sufficient.
15th Aug 2023, 9:33 AM
Darpan kesharwani🇮🇳[Inactive📚]
Darpan kesharwani🇮🇳[Inactive📚] - avatar
+ 7
Because input is a string function and if we want to take integer values through input then we should convert into integer.
15th Aug 2023, 8:55 AM
Sakshi
Sakshi - avatar
+ 2
"input()" itself only accepts a string. We can convert it into different variables we want
15th Aug 2023, 10:18 AM
Programmer
Programmer - avatar