Sep-13-2019, 04:16 AM
(Sep-12-2019, 06:48 AM)buran Wrote: introduce if/elif/else block in the loop bodyOk I've managed to create a for loop with an if/elif block nested within (below). However, the way that I've implemented "current_score + points" gives the point value for each alien instead of a running total like the question asks for.
aliens = ['red', 'red', 'red', 'red', 'red', 'blue', 'blue', 'blue', 'green', 'green'] current_score = 0 for alien in aliens: if alien == 'red': print(current_score + 5) elif alien == 'blue': print(current_score + 10) elif alien == 'green': print(current_score + 20)