The newbie Python struggle is real!


#1

Q words
Exercise goal: Practice using for loops.

We have a list of words.

Instructions
Your job:

Use a for loop to find and print the words that start with "q" in this list.

words = ['zip', 'blip', 'croissant', 'toast', 'quip', 'quail', 'quetzal', 'quizzical']
for word in words:
if words[0] in words == 'q':
print word[0]


#2

Did you mean to write, word[0] (a character)? words[0] is the first word in the list.

Without the code sampel being formatted we cannot tell if there is an issue with indentation. Please look for the article on "How to format code samples in posts".

Help > Q & A Forums > How to format code

#3

it was suppose to be if word[0] in words == 'q':


#4

words = ['zip', 'blip', 'croissant', 'toast', 'quip', 'quail', 'quetzal', 'quizzical']

for word in words:
     if word[0] in words == 'q':
           print word[0]

Is there a question, here? Also, please read up on code formatting (Help category).


#5

ok i got it all worked out now! thanks


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.