Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # въвеждаме докато не получим Going home
- command = input()
- # извървени стъпки(число под формата на текст -> "2000") или "Going home"
- # спираме да вървим: command == "Going home"
- # продължаваме: command != "Going home"
- target_steps = 10000
- total_steps = 0
- while command != "Going home":
- # "1234" -> число
- # извървени стъпки -> добавяме към общия брой -> проверка дали сме достигнали целта
- walked_steps = int(command)
- total_steps += walked_steps
- if total_steps >= target_steps:
- break
- command = input()
- else: # command e "Going home"
- steps_to_home = int(input())
- total_steps += steps_to_home
- # проверка достигнал ли съм целта
- if total_steps >= target_steps:
- print("Goal reached! Good job!")
- print(f"{total_steps - target_steps} steps over the goal!")
- else:
- print(f"{target_steps - total_steps} more steps to reach goal.")
Advertisement
Add Comment
Please, Sign In to add comment