Why?? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок


What is the purpose of converting strings to integers isn’t it simpler to just say >>>print(3+4) 7 Then >>> print(int(“3”) + int(“4”)) 7

16th Jun 2018, 9:16 AM
John Austin
John Austin - avatar
2 ответов
+ 11
Converting strings to integers is useful when getting user input: x = int(input()) y = int(input()) print(x + y)
16th Jun 2018, 10:18 AM
A Fox
A Fox - avatar
+ 5
The example is just there to show you how to convert string to integer values so that you can add them. There's no practical reason for you to write the latter over the former, if you just want to add two numbers.
16th Jun 2018, 9:34 AM
Hatsy Rei
Hatsy Rei - avatar