Advertisement
SimeonTs

SUPyF2 Lists Basics Exercise - 01. Invert Values

Oct 3rd, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. """
  2. Lists Basics - Exercise
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1725#0
  4.  
  5. SUPyF2 Lists Basics Exercise - 01. Invert Values
  6.  
  7. Problem:
  8. Write a program that receives a single string containing numbers separated by a single space.
  9. Print a list containing the opposite of each number
  10. Example
  11. Input           Output
  12. 1 2 -3 -3 5     [-1, -2, 3, 3, -5]
  13. -4 0 2 57 -101  [4, 0, -2, -57, 101]
  14. """
  15. print([abs(int(digit)) if int(digit) < 0 else -abs(int(digit)) for digit in input().split(" ")])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement