Can some help me with this | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can some help me with this

I am stuck at get the sum of the integers https://www.sololearn.com/post/1712452/?ref=app

14th Oct 2022, 10:02 AM
T0N1
T0N1 - avatar
8 Answers
+ 1
You can approach the task like this: – get user input() and store it in a variable – convert the input to in integer – initialize a result variable with 0 – use range() function and a for-loop to iterate over the range – in each iteration add the current number to the result variable – after the loop, print the result variable
14th Oct 2022, 10:11 AM
Lisa
Lisa - avatar
+ 1
⭐⭐⭐ – after the loop, print the result variable ⭐⭐⭐ If you need help with your code, please link your code so we can check on it.
14th Oct 2022, 10:22 AM
Lisa
Lisa - avatar
+ 1
Unindent the last line with the print(). Currently your print is inside of the loop. For the task we need it outside of the loop. You can link your code like this: Go to Code section, click +, select the programming language, insert your code, save. Come back to this thread, click +, Insert Code, sort for My Code Bits, select your code.
14th Oct 2022, 10:30 AM
Lisa
Lisa - avatar
+ 1
Thanks 🙏 It works now
14th Oct 2022, 10:31 AM
T0N1
T0N1 - avatar
+ 1
Great! :)
14th Oct 2022, 10:33 AM
Lisa
Lisa - avatar
0
Please do not put links in the tag section. Put the relevant programming language there. You can put the link in the description.
14th Oct 2022, 10:03 AM
Lisa
Lisa - avatar
0
It has been updated
14th Oct 2022, 10:08 AM
T0N1
T0N1 - avatar
0
But it is printing the sum of the numbers individually not the final sum only
14th Oct 2022, 10:20 AM
T0N1
T0N1 - avatar