lundi 6 août 2018

Add and subtract from two list following if-else condition in Python

Here is what I have tried

c = ['8781' ,'2740', '1413', '3060', '5074']
d = ['8853' ,'2812', '1355', '2986', '5107']

start = map(int, c)
end = map(int, d)

for n,m in zip(start,end):
    if n < m:
        preS = map(lambda x:x-21, start)
        preE = map(lambda x:x+20, end)
        print (preS, preE)
    else:
        preS = map(lambda x:x-20, start)
        preE = map(lambda x:x+20, end)
        print (preS, preE)

Here my else part of loop is not executing and I got multiple lines of same output. Whats wrong here? I would really appreciate for answers.

Aucun commentaire:

Enregistrer un commentaire