How to sum all range output in python 3 -


this simple question want sum range output code flow

for b in range (1, 11):     ui  = (b**b)     print (ui) 

the output

1 ------------------ 4 ------------------ 27 ------------------ 256 ------------------ 3125 ------------------ 46656 ------------------ 823543 ------------------ 16777216 ------------------ 387420489 ------------------ 10000000000 ------------------ 

but want sum of these answer. please me.

you can use generator expression within sum function

>>> sum(i**i in range(1,11)) 10405071317 

Popular posts from this blog