So, there are two small questions here:
a)
my_list = ['apple', 'banana', 'grapes', 'pear']
for c, value in enumerate(my_list, 1):
    print(c, value)
Step as follows:
- enumerate(my_list, 1)will get a list with index, here the output is a enumereate object, if use- list(enumerate(my_list, 1)to have a look, it is- [(1, 'apple'), (2, 'banana'), (3, 'grapes'), (4, 'pear')].
- So, with every for, the first iterate getc=1, value='apple', the second getc=2, value='banana'...
- Then the final output is:
1 apple
2 banana 
3 grapes 
4 pear
b)
[print(int(x)==sum(int(d)**p for p,d in enumerate(x,1)))for x in[input()]]
Step as follows:
- First, it's a list comprehension, I suppose you have known that.
- The inputfirst expect a user input, let's input100for example, then theinputwill treat it as astr, so[input()]returns['100']
- Then with for x in [input()]thexis'100'
- Next according list comprehension, it will handleint(x)==sum(int(d)**p for p,d in enumerate(x,1))
- (int(d)**p for p,d in enumerate(x,1))will first iterate '100', get something like- [(1, '1'), (2, '0'), (3, '0')]if use list to see it, just similar as example 1. Then calculate- int(d)**pfor every iterate and finally use- sumto get the result, similar to- int('1')**1 + int('0')**2 + int('0')**3, the result is- 1.
- So print(int('100')==1certainly outputFalse
- And the return value of printfunction call is alwaysNone, solist comprehensionwill make the new list is[None].
- So the final outout is (NOTE: 100 is the echo of your input):
>>> [print(int(x)==sum(int(d)**p for p,d in enumerate(x,1)))for x in[input()]]
100
False
[None]