For my assignment, I have to use a for loop and a range function for a program to print out the following, each on a separate line so it looks like a list.
Hello 0
Hello 1
Hello 3
Hello 6
Hello 10
I know that you have to create two variables, one that keeps track of the number of indexes and another that prints that, because the question states:
(the number corresponds to the accumulated summation over the successive indexes). My problem is creating the function that does so keeping track of the indexes. Any guidance would be great. Thanks again in advance.
count_indexes = ?
print_statement = count_indexes + 1
for i in range(0,11,count_indexes):
print("Hello",print_statement)
The expected result should print hello 5 times, each on different lines, each with different numbers on them, and the numbers should be 0,1,3,6,10.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…