Given the list numbers, use a list comprehension with a ternary expression to create a list called s
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
Problem
Given the list numbers, use a list comprehension with a ternary expression to create a list called signs. Each element should be 1 if the number is positive (> 0), 0 if zero, or -1 if negative. Print signs.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.