The program asks for a number and then prints out all the positive integer values from 1 up to the number. However, the order of the numbers is changed so that each pair or numbers is flipped. That is, 2 comes before 1, 4 before 3 and so forth. For example:
Please type in a number: 6214365
num = int(input("Please type in a number: "))r = 2t = 1while True: if t >= num: break print(r) print(t) r += 2 t += 2
The code works fine with even numbers but then struggles with odd numbers. For example with the input 5 the result should be:
Please type in a number: 521435
But instead my output comes out as:
Please type in a number: 52143
Any help would be appreciated.