navgurukul / newton

Includes all our curriculum for all the courses.
https://merakilearn.org/
GNU General Public License v3.0
26 stars 81 forks source link

Python debugging part3 debugging question1 #59

Open utterances-bot opened 5 years ago

utterances-bot commented 5 years ago

Python debugging part3 debugging question1

http://saral.navgurukul.org/course?id=18&slug=python__debugging-part3%2Fdebugging-question1

anuragrawat19 commented 5 years ago

def numbers_greater_than_twenty(list1): i=0 new_list=[] while i<len(list1): if list1[i] < 20: new_list.append(list1[i])

    i=i+1
return new_list

list2=[12, 312, 42, 123, 5, 12, 53, 75, 123, 62, 9] num_list=numbers_greater_than_twenty(list2) print "initial list was ",list2 print "new list which has number less than 20 is :",num_list

i have used "new_list" as a new list appended all the numbers which are less than 20 .My code is working but i am confused that whether it can be solved through remove() function or not.

abhishekgupta92 commented 5 years ago

No, please avoid using remove. @raghavanu