Hello everybody, this is a Python program which finds out the smallest and largest number in the list.

Here we use 2 predefined functions min() and max() which check for the smallest and largest number in a list respectively.

**You can watch the video on YouTube ****here**

#### Largest and Smallest in a list – Code Visualization

#### Task :

To find largest and smallest number in a list.

#### Approach :

- Read input number asking for length of the list using
`input()`

or`raw_input()`

. - Initialise an empty list
`lst = []`

. - Read each number using a
`for loop`

. - In the for loop append each number to the list.
- Now we use predefined function
`max()`

to find the largest element in a list. - Similarly we use another predefined function
`min()`

to find the smallest element in a list.

#### Program :

1 2 3 4 5 6 7 8 |
lst = [] num = int(input('How many numbers: ')) for n in range(num): numbers = int(input('Enter number ')) lst.append(numbers) print("Maximum element in the list is :", max(lst), "\nMinimum element in the list is :", min(lst)) |

#### Output :

##### Course Suggestion

Want to learn python with strong fundamentals? If yes, I strongly suggest you to take the course below.

Course: Fundamentals of Programming in Python

program failed if i input negative number

num=list()

print(“how many numbers you want to enter ends”)

n=int(input())

ctr=1

if n>0:

while ctr”)

val=int(input()

num.append(val)

ctr+=1

max n=num[o];

min n=num[0];

for i in range(len[num]):

max n=num[i];

if(num[i]<min n):

min n=num[i];

print("the mximum value in the list is",max n)

print("the minimum value in yhe list is",min n)

i need thye answer