'if (the element that has index [0] in a list) is the smallest number in the list : print("x") How can i retype this in python?
I am trying to type a code that return diferent string messeges depending on the place of the smallest number in a list. for example .. if the smallest number in the list has index [0] so i want him to print "x" .... and if the smallest number has index [1] so i want him to print "y" ..... and so on
I tried the next code but it is not working correctly ...... any explanation please?
list1 = [5, 2, 3]
if list1[0] is min(list1):
print("it is x")
elif list1[1] is min(list1):
print("it is y")
elif list1[2] is min(list1):
print("it is z")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
