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?
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 >>>
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.