continue statement | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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')

7th Jan 2020, 6:50 PM
Abdelhakim Dahaman
Abdelhakim Dahaman - avatar
2 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
7th Jan 2020, 7:04 PM
Tibor Santa
Tibor Santa - avatar
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?
7th Jan 2020, 7:51 PM
Jnn
Jnn - avatar