Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python – weird number counter printer thingie

numbers = int(input())

Hi,
I was also given this homework python thingie to do. I am supposed to solve it using some loop or cycle. But I am really lost, because I have no idea, how to solve it. Can someone of you please help me.

"Read a string containing only digits from the input. Print to the output a string that contains each digit from the input as many times as the value of the digit."

Input: 25104

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Output: 225555514444

>Solution :

You can use a for loop:

for number in str(numbers):
    print(number * int(number), end='')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading