• Python question of the day

    What would be the output of executing the following code:
    a, b, c = (1, 2, 3, 4, 5, 6, 7, 8)[1:6:2]
    print(b)
     2
     3
     4
     ValueError
    Explanation:
    [1:6:2] instructs to take every other element (step 2) from first element to sixth element and assign it to a,b,c respectively. so, from the tuple (1, 2, 3, 4, 5, 6, 7, 8) 2,4,6 are assigned to a,b,c respectively


    Top 100 python interview questions:






datai analytics