Easier way to solve "Simple Errors"?


#1



https://www.codecademy.com/en/courses/python-beginner-en-cxMGf/0/4?curriculum_id=4f89dab3d788890003000096


Hey everyone, i was wondering if While conditions accept lists? I feel that if I make a list which consists of all acceptable raw inputs ( y, n, Y, N, Yes, No) ? I haven't tried this but just wanted to know if it would be an acceptable input for this exercise?



#2

A carefully crafted while statement could be made to evaluate a list, but the condition would depend on something like what's in the list, if the list has any length, or something is not in the list, or no longer in the list.

>>> nums = ['one', 'two', 'three', 'four']
>>> while len(nums) > 0:
    print (nums.pop())

    
four
three
two
one
>>>

>>> nums = ['one', 'two', 'three', 'four']
>>> while 'one' in nums:
	print (nums.pop())

	
four
three
two
one
>>>

#3

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