+ 2

fill in the blank to print 37

a,b,*c = [1,2,3,7] print(____) explain me please

19th Jul 2020, 7:34 AM
Smiley[Offline]
3 Antworten
+ 3
Look at your variable definition. To the left of the assignment operator we see three variables <a>, <b> and <c>. And to its right we see a list with four elements [ 1, 2, 3, 7 ]. There are 3 variables, but the list has 4 elements. So how it works? notice the asterisk * before c -> *c, it means the remaining elements from the list (starting from the third element) will all be stored into <c> as an iterable (a list in this case). So the values of <a>, <b> and <c> would be ... a -> 1 # first list element b -> 2 # second list element c -> [3, 7] # third and successive list elements - as list So to print 37 here you print all the values in list <c> while specifying the item separator to be a blank, so each item will appear as if they were concatenated. print(*c, sep = '')
19th Jul 2020, 7:52 AM
Ipang
+ 1
print (*c)
19th Jul 2020, 7:40 AM
Sâñtôsh
Sâñtôsh - avatar