Enumerate index and number + time questions

Asked 2 years ago, Updated 2 years ago, 214 views

Assume you have the following list:

a=list(range(1,6)))
a. reverse()

At this time, the following code will succeed.

b=[i+g for i, gin enumerate(a)]
print(b)

"i appears as ""can not assign to operator"" for the code below."

b=[]
for i,gin enumerate(a):
    i+g=c
    b.append(c)
print(b)

Why is it not good to write separately, even though it works well if it is written with the inclusion?
I think this is a rudimentary point, but I look forward to hearing from you.

python

2022-09-30 21:58

1 Answers

i+g=c was misaligned, and the correct one was c=i+g.
Thank you for your comment.


2022-09-30 21:58

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.