Smallest Element in List
Advanced
Smallest Element in List
Hey there, budding coder! Today, we're going to play a little game with lists. Have you ever tried to find the smallest thing in a pile of toys or books? Well, this challenge is very similar. Here, you will write a function to find the smallest number in a list.
Your Mission:
Write a function called smallest_element_in_list which receives a list of numbers and returns the smallest number in that list.
Rules:
- The list will contain at least one number.
- There might be negative numbers in the list!
- Do not print anything, just return the smallest number.
Example Magic:
Imagine you have these lists and you run them through your function:
smallest_element_in_list([3, 7, 2, 5])
This should return 2 because 2 is the smallest number in the list.
smallest_element_in_list([-1, 3, -5, 0])
This should return -5 because -5 is the smallest number in this list.
It's your turn now! Write a function that finds the littlest of them all!
Inputs
Arg 1:
[3,7,2,5]Expected Output
2Actual Output