samedi 16 février 2019

If statements in loop (python)

I have 20 sectors and want to print my points per sector. With a bunch of if statements it looks like this:

if sector == 0:
    print(1)
if sector == 1:
    print(2)
if sector == 2:
    print(3)
...
if sector == 19:
    print(20)

How do I make this shorter and put it in a loop?

Aucun commentaire:

Enregistrer un commentaire