Python: Function that takes a sequence of numbers and determines if all are different from each other
Python Basic - 1: Exercise-1 with Solution
Write a Python function that takes a sequence of numbers and determines if all the numbers are different from each other.
Python Code :
def test_distinct(data): if len(data) == len(set(data)): return True else: return False; print(test_distinct([1,5,7,9])) print(test_distinct([2,4,5,5,7,9]))
Visualize Python code execution:
The following tool visualize what the computer is doing step-by-step as it executes the said program:
Python Code Editor :
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
- New Content published on w3resource :
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework