Aug-29-2019, 07:21 PM
Basic question from a complete noob. I'm sorry.
Testing if statement and for loops. Populating a list, creating an empty list, finding some values and appending that new empty list. I then want to just print that list.
If I print within the 'if' statement it outputs but I don't want to see the entire iteration.
I can also print the list after the program has completed.
But, I'd like the if statement to finish and then as the next command print the list.
Missing something simple / dumb here. Sorry. Suggestions / corrections?
Testing if statement and for loops. Populating a list, creating an empty list, finding some values and appending that new empty list. I then want to just print that list.
If I print within the 'if' statement it outputs but I don't want to see the entire iteration.
I can also print the list after the program has completed.
But, I'd like the if statement to finish and then as the next command print the list.
Missing something simple / dumb here. Sorry. Suggestions / corrections?
>>> fruits=['apples', 'bananas', 'oranges'] >>> vowel_names=[] >>> print(vowel_names) [] >>> for i in fruits: ... if i[0] in "aeiou": ... vowel_names.append(i) ... print(vowel_names) File "<stdin>", line 4 print(vowel_names) ^ SyntaxError: invalid syntax