pist = ['P58', 'P60', 'P0']
def print_it:
For i in pist:
if i == 'P0':
print('yes')
elif i == 'P58':
print('yup')
else:
print('No')
So this is the issue: I want the function to print 'yes' as long as P0 is in the list(irrespective of whether P58 is in it) but it keeps printing 'yup' because P58 is the first item on the list. Can there be another way? Note: the list cannot be changed.
CodePudding user response:
def print():
if 'P58' in pist:
return 'yes'
elif 'P0' in pist:
return 'yup'
else:
return 'No'
CodePudding user response:
if 'P58' in pist:
print('yes')