+ 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
3 Respuestas
+ 2
Is this what you asked for?:
print(variable1 + \
variable2 + \
variable3 + \
variable4 + \
...
variableN)
+ 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)
+ 1
Yes, this what I m looking for. Thanks Seb :-)