简体   繁体   中英

How to create python program, multiple of 3 with while loops

ok first sorry if my english is bad

i want to ask how to create python programs multiple of 3 with while loop, like this:

i=0
while i < 10:
   i += 1
   if i == 3:
     continue
   print(i)

output:
1
2
4
5
6
7
8
9
10

so i want to eliminate the number 3 6 9, can anyone help me? i newbie:'v thanks.

It seems as if you want to print the numbers in reverse order (backwards/upside-down), so here is the snippet of code to achieve that task:

i=10
while i > 0:
   if i%3 != 0:
     print(i)
   i-=1

The value of 'i' is the number which it will start counting down from.

i=0
while i < 10:
   i += 1
   if i % 3 == 0:
     continue
   print(i)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM