sibinasto

10.04. Walking

Dec 2nd, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. target_steps = 10000
  2. current_steps = 0
  3. going_home = False
  4. while current_steps < target_steps:
  5.     command = input()
  6.     if command == 'Going home':
  7.         going_home = True
  8.         break
  9.     steps = int(command)
  10.     current_steps += steps
  11. if going_home:
  12.     steps = int(input())
  13.     current_steps += steps
  14. difference = abs(current_steps - target_steps)
  15. if current_steps >= target_steps:
  16.     print('Goal reached! Good job!')
  17.     print(f'{difference} steps over the goal!')
  18. else:
  19.     print(f'{difference} more steps to reach goal.')
Advertisement
Add Comment
Please, Sign In to add comment