Workout #17: How Many Different Numbers

Oct 2, 2021

In this exercise, you can assume that your Python program contains a list of integers. We want to print the number of different integers contained within that list. Thus, consider the following:

numbers = [1, 2, 3, 1, 2, 3, 4, 1]
ans = 4

Write a function, called how_many_different_numbers, that takes a single list of integers and returns the number of different integers it contains.

TRY IT YOURSELF

ANSWER

https://colab.research.google.com/drive/1WwLeL0tEj4eJD2EHHGsi_a8EEXo9_5ux?usp=sharing

--

--

Abish Pius
Abish Pius

Written by Abish Pius

Data Science Professional, Python Enthusiast, turned LLM Engineer

No responses yet