Larger than n Lab HELP ITS FOR SCHOOL PLZ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Larger than n Lab HELP ITS FOR SCHOOL PLZ

I have a lab assignment and have everything done except this last bit of code that is me creating a list of numbers greater than n the list is made by the user n is also a user input for the sake of this I’ll choose number 5. I’m also going to make a list1= [2,4,7,8,9,10,7,5] So far I have list2 = [] for values in list1: if values > 5: list2.append(values) print(list2) But it prints [7] [7,8] [7,8,9] [7,8,9,10] [7,8,9,10,7] How can I fix this so it shows one list?

6th Nov 2020, 8:03 AM
SpeedyJabba
SpeedyJabba - avatar
1 Answer
0
SpeedyJabba , the reason is indentation of print. Indent print with the for loop.
6th Nov 2020, 8:10 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar