dimanche 7 mars 2021

How to print numbers in pairs...?

I'm a sort-of beginner in python. I've got a problem: how do I print numbers in pairs until it reaches the number the user wants, but like the number-pairs are turned around? Like this:

number = int(input("Give a number: "))

if the number is for example, 5:

2

1

4

3

5

Preferably using while / while True / for / if - sentences, not a function. I coded one where it got til' number 4 and one where it was just a infinite loop... This is probably quite simple, but I can't figure it out. Thanks in advance for any advice or tips from you guys. Also this is my first time using stackoverflow.com so not sure if I know how to quite work this site yet.




Aucun commentaire:

Enregistrer un commentaire