Rewrite following program using for loop:
no=3456
while no>0 :
print(no%10)
no=no/10
(Python)
Answers
Answered by
5
Question:-
➡ Rewrite the following program using for loop.
Solution:-
Given code snippet,
no=3456
while no>0:
print(no%10)
no=no/10
Using for loop, the program will be,
no=3456
s=str(no)
for i in range(0, len(s)):
x=str(no%10)
print(x)
no=no/10
s=x
Similar questions