09.Loading Bar problem
Здравейте,
Някой може ли да предложи по-адекватно решение на тази задача. Аз я направих с безумно много проверки, ако някой ми покаже по-опростен вариант ще съм безкрайно благодарна!
https://pastebin.com/DG3mRtXk
Условие на задачата:
Loading Bar
You will receive a single number between 0 and 100 which is divided with 10 without residue (0, 10, 20, 30...).
Your task is to create a function that visualize a loading bar depending on that number you have received in the input.
Examples
|
Input |
Output |
|
30 |
30% [%%%.......] Still loading... |
|
50 |
50% [%%%%%.....] Still loading... |
|
100 |
100% Complete! [%%%%%%%%%%] |
def loading_bar(n): ready=("%"*int(n/10)) remain=("."*int(10-n/10)) loading_bar = ready+remain return loading_bar n = int(input()) if n==100: print(f'100% Complete!\n[{loading_bar(n)}]') else: print(f'{n}% [{loading_bar(n)}]\nStill loading...')