dimanche 3 décembre 2017

Printing out list with proper if conditions in python

k1 = ['UCF', 'Mario', 'JonnnyStorm']
k2 = [10, 14, 5]
k3 = [300, 700, 600]

for p,g,h in zip(k1,k2,k3):
    if k2 > 10 and k3 > 400:
        print p,g,h

What I want to see is

Output:

Mario 14 700

What i get is

Output:

UCF 10 300
Mario 14 700
JonnnyStorm 5 600

Even when I switch and play with the conditions, I still get totally wrong answers I do not expect. I must be missing something Vital.

Also if I could print it out as

Mario has 14 Points and is at Rank 700.

That would be great. I tried that to with %s and %d with the normal print syntax and was getting wild errors. If anyone could not only get me an answer but a detailed explanation of what your doing that would be great. I really want to understand why.

Aucun commentaire:

Enregistrer un commentaire