Code Not Working | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Code Not Working

I used this code to solve the problem below in my IDE on my computer. It worked. But it won't work on Sololearn playground. I'm trying to get the sum of consecutive numbers from 1 - 50 #my code N = int(input("Enter a number: ")) list = list(range(N)) sum = sum(list) print (sum) The problem below: No one likes homework, but your math teacher has given you an assignment to find the sum of the first N numbers. Let’s save some time by creating a program to do the calculation for you! Take a number N as input and output the sum of all numbers from 1 to N (including N). Sample Input 100 Sample Output 5050 Explanation: The sum of all numbers from 1 to 100 is equal to 5050.

11th Feb 2021, 11:27 AM
Oyintare Tugbokorowei
2 Answers
+ 4
Carefully read what is written in the yellow box "Remember, range(a, b) does not include b, thus you need to use b+1 to include b in the range." Also check my comment again https://www.sololearn.com/Discuss/2686447/?ref=app
11th Feb 2021, 11:34 AM
Simba
Simba - avatar
+ 1
Show here your attempt to solve the problem so that anyone may help you
11th Feb 2021, 11:32 AM
Mohd Aadil
Mohd Aadil - avatar