Answer the question
In order to leave comments, you need to log in
How to declare a list item in a variable in python?
I have a list with words, I need to find words with commas in this list and add them to a separate list.
I'm trying to do this:
for word in words:
i = len(word) - 1
if word[i] == ",": #or the find method
word_with_comma.append(???????)
Answer the question
In order to leave comments, you need to log in
word_with_comma = [word for word in words if ',' in word]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question