Tuesday, June 30, 2020

Python single line for loop

# example of single line for loop
x = [1,2,3,4]
print( sum(e for e in x) )

I can get 10. What if we don't have a single line for loop?

s = 0
for e in x:
    s += e
print(s)

No comments:

Post a Comment

Task in UnrealEngine

 https://www.youtube.com/watch?v=1lBadANnJaw