0
Please write and explain the coding for the given python pattern(using while loop).
8642 864 86 8
2 odpowiedzi
0
i = 0
n = "8642"
while len(n) != 0:
print(n)
n = n[0: len(n[:-1])]
You proceed the number as a string.
Strings are sliceable.
The orientation is the lenght of the string.
Take the rules of slicing and iterate it until the len of the given string is 0.
Edit:
https://code.sololearn.com/ca1FVvy5qmwW/?ref=app
with comments
Sorry, it is hard to explain for me.
Maby you train slicing, then you will get it.