145k views
4 votes
X = 0

end = int(input("Pick a number: "))
for num in range(1, end, 2):
#missing line
print(x)
X 10.
This program should print the sum of all the ODD numbers between 1 and the user's number pick the "end" variable)
Write the missing line that will make that possible.
I think its print(1 + end) but If its wrong can I please have feedback cause I'm struggling with this 1.

X = 0 end = int(input("Pick a number: ")) for num in range(1, end, 2): #missing-example-1
User THelper
by
5.6k points

1 Answer

3 votes

The missing line would be x+= num

This means that every time a number is selected from the range it is added to the value of x.

User Stuart Cook
by
5.6k points