main.py56 chars5 lines
In the above code, we initialize a variable sum
to 0. We then use a for loop to iterate from 1 to 100 using the range()
function. For each iteration, the value of i
is added to sum
. Finally, the value of sum
is printed to the console using the print()
function. This will output 5050
, the sum of numbers from 1 to 100.
gistlibby LogSnag