0
I want to put the for Loops and the sum together is that possible in python ?
2 Respostas
+ 2
Yes, it is possible as Diego demostrates, but we don't know exactly what do you want to do. If you already have a working code you can share it here so we can guide you further.
+ 1
How to write for loop in one line ?
x="123"
sum=0
for i in x:
sum=sum+int(i)
print("sum of digits is",sum)
I want to write this for loop in one line how can I do that ?
https://code.sololearn.com/cLXij8Zqajo7/?ref=app