+ 1
while Loop
>>> numbers=list(range(2,20,2)) >>> print(numbers) [2, 4, 6, 8, 10, 12, 14, 16, 18] How can i print ! with every number from above list. need following result: 2! 4! 6! 8! so on
6 odpowiedzi
+ 5
Or you can do what David did but do:
print(i,end="!\n")
+ 4
for i in numbers:
print(str(i) + '!')
+ 1
Thanks David...got it.
>>> x=0
>>> while x<=max_index:
z=numbers[x]
print(str(z)+"!")
x=x+1
2!
4!
6!
8!
10!
12!
14!
16!
18!
>>>
+ 1
x += 1
It's cleaner code
+ 1
x += 1
instead of
x = x + 1
0
What so you mean by cleaner code?