0
continue statement
Hi everyone, i want this code to only print out the words that dont contain 'aAbBcC'. But if i run this it prints all the words in the list, despite having 'aAbBcC' in them. Can anyone give me a tip on how to write this piece of code correctly? words = ['hello','how','are','you','doing','today'] for i in words: if i in 'aAbBcC': continue print(i) print('bye')
3 Answers
+ 1
if any(c in 'aAbBcC' for c in i):
Because you want to cross-check all the characters in each word and in case any match, continue to next word
0
Try:
if 'aAbBcC' in i:
continue
Cause doing it your way you check if i is a part of 'aAbBcC'
Or do you want to check if i contains any of these chars?