def whileloop(top, stop, step):
i = 0
numbers = []
for i in range(top, stop, step):
print(f"At the top of i is {i}")
numbers.append(i)
i += 1
print("Numbers now: ", numbers)
print(f"At the bottom i is {i}")
print("The numbers: ")
for num in numbers:
print(num)
whileloop(0, 7, 1)
以上为练习5,首先定义函数和形参,使用for循环和range函数实现功能,最后调用whileloop函数实现赋值。



