I want to print numbers in a specific order. For example I want to print numbers 1 to 7
while number < 7:
number += 1
print(number)
It gives:
1
2
3
4
5
6
7
but output I would like is:
1
2
4
3
5
6
7
>Solution :
I can’t comment b/c my rep is so low, but this would give the desired output lol. Not sure what you would use this for but you can make a dictionary and output it in a while loop.
number = {1:1,
2:2,
3:4,
4:3,
5:5,
6:6,
7:7
}
num = 1
while num < 8:
print(number[num])
num += 1
Gives:
1
2
4
3
5
6
7