What is the result of this code? nums = [10, 9, 8, 7, 6, 5] nums[0] = nums[1] - 5 if 4 in nums: print(nums[3]) else: print(nums[4]) How does this works?
4/16/2020 8:39:19 AM
PRIYANKA K2 Answers
New Answernums = [10, 9, 8, 7, 6, 5] nums[0] = nums[1] - 5 # change 1st element with 2nd element minus 5 (9 - 5 -> 4) print(nums) # see how <nums> had changed, 1st element is now 4, not 10 anymore if 4 in nums: # does <num> contain 4? yes print(nums[3]) # print the 4th list element -> 7 else: # if <nums> doesn't contain 4 print(nums[4]) # print the 5th list element -> 6
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message