+ 1

How to write very long codes in structured way in python

For example I have int variables like more than 10 and want to print sum of it. e.i. print( variable1 + variable2 + variable3 + variable4 + ....continue). If i type all code in one sentences its looks very clumsy Anyone has any classy way to arrange it and look good coding page

30th Sep 2019, 5:41 AM
Deep Singha
Deep Singha - avatar
3 ответов
+ 2
Is this what you asked for?: print(variable1 + \ variable2 + \ variable3 + \ variable4 + \ ... variableN)
30th Sep 2019, 7:42 AM
Seb TheS
Seb TheS - avatar
+ 2
Try placing the variables inside an array, and then ultize while to sum each one like this: array = [var1, var2, var3...] x = 0 result = 0 while x < len(array): result += array[x] x += 1 print(result)
30th Sep 2019, 5:54 AM
Wardy Spirit
Wardy Spirit - avatar
+ 1
Yes, this what I m looking for. Thanks Seb :-)
30th Sep 2019, 1:10 PM
Deep Singha
Deep Singha - avatar