SimplyMiah

Hello Repel community,
I am stuck on a CodeHS question titled: Better Sum. Can you guys please help me with this, it means the world to me, thank you <3
Here is the problem :)

Write a program that asks the user for two numbers. Using a for loop, add all of the numbers from the first to the second.
For example if the first number is 6 and the second number is 8 the result is 21 (6 + 7 + 8).
Print out the results when you are finished.

You are viewing a single comment. View All
Bookie0

hi there!

what language is this?

so first of all, to ask the user for 2 numbers you'll need an input. Then for the for loop, in python its for i in range(x) and replace x with the number you want or the variable you want.
you say the for loop has to add all the numbers from the first to second, so can maybe store the 1st number in a variable, say a and then increment a by one. Next add those two numbers together. do this until the 2nd number. To determine how many times the loop runs, you have to find out how many numbers between the 1st and the 2nd, so this can be achieved with a substraction.

then to print the results, use print.

Im assuming its in python, here is the brief program (spoiler alert)

So yea, if you need more help or if i was unclear, please tell me and I will try to help you ;)