Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- num = int(input())
- salary = int(input())
- for i in range(num):
- apps = input()
- if apps == 'Facebook':
- salary -= 150
- elif apps == 'Instagram':
- salary -= 100
- elif apps == 'Reddit':
- salary -= 50
- if salary <= 0:
- print('You have lost your salary.')
- break
- if salary > 0:
- print(salary)
- Решение с тернарен оператор:
- num = int(input())
- salary = int(input())
- for i in range(num or salary <= 0):
- apps = input()
- salary -= 150 if apps == "Facebook" else 100 if apps == "Instagram" else 50 if apps == "Reddit" else 0
- print(salary if salary > 0 else "You have lost your salary.")
- Решение с while и тернарен оператор:
- num = int(input())
- salary = int(input())
- while num != 0 and salary > 0:
- apps = input()
- salary -= 150 if apps == "Facebook" else 100 if apps == "Instagram" else 50 if apps == "Reddit" else 0
- num -= 1
- print(salary if salary > 0 else "You have lost your salary.")
Add Comment
Please, Sign In to add comment