What is the problem ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
15th Sep 2023, 7:55 PM
Yassine
Yassine - avatar
6 Answers
+ 1
You have to define the variable sum first And then print it or simply just print(a+b)
16th Sep 2023, 9:44 PM
Mahla Keshvari
Mahla Keshvari - avatar
+ 6
# Get input as integers a = int(input("entrez votre nombre :\n")) b = int(input("entrez votre nombre :\n")) # Add a+b and assign to new variable 'sum' sum = a+b print(sum) We do not need to convert sum to integer because Python does this automatically for us and is called implicit data type conversion. https://www.geeksforgeeks.org/type-casting-in-python/amp/
15th Sep 2023, 8:16 PM
Keith
Keith - avatar
16th Sep 2023, 10:13 AM
Yassine
Yassine - avatar
+ 4
When you take input using input(), it's stored as a string by default. You need to convert the input values to integers before performing arithmetic operations. The assignment of sum is incorrect. You should directly calculate the sum of a and b rather than using sum = a + b. Instead, you can do sum = int(a) + int(b) to correctly calculate the sum
15th Sep 2023, 7:57 PM
JAY
JAY - avatar
+ 4
Continue.... Here, is your modified code, hope it's helpful to you. https://code.sololearn.com/cy3K2wlsSEW3/?ref=app
15th Sep 2023, 8:57 PM
Sakshi
Sakshi - avatar
+ 4
Yassine welcome 👍 Happy learning and happy coding 😊
16th Sep 2023, 11:44 AM
Sakshi
Sakshi - avatar