names = ['anne', 'beth', 'george', 'damon'] ages = [12, 45, 32, 102] for name,age in zip(names,ages): #print('name:'+ name + ',ages:' + str(age)) print("name:",name,"ages:",age)
result:
name: anne ages: 12 name: beth ages: 45 name: george ages: 32 name: damon ages: 102
example2:
a = ['aaa','bbb','ccc','ddd'] for index, aaa in enumerate(a): if 'aaa' in aaa: a[index] = 'bbb' print(a)
result :
['bbb', 'bbb', 'ccc', 'ddd']