Aug-26-2019, 04:09 AM
Hey guys..
I wanted to have a loop from list of tuples where i can extract name of husband by giving name of wife..
I got that ... but when I am trying to put one more statement so that if name is not available, it can give precautionary statement, I am having problems.. Please see the code below and suggest what I can do..
PS I do not want to convert it into dictionary.
I wanted to have a loop from list of tuples where i can extract name of husband by giving name of wife..
I got that ... but when I am trying to put one more statement so that if name is not available, it can give precautionary statement, I am having problems.. Please see the code below and suggest what I can do..
PS I do not want to convert it into dictionary.
husbands=[('ginny','harry'),('eve','adam'),('lizzy','darcy'),('rose','jack')]
wife=input('write wife name here = ')
for x in husbands:
if wife == x[0]:
loved = x[1]
print('her husband is ',loved)
elif wife != x[:]:
print('name is not available')
