# Highly Recommended Python Program of List for beginner

Highly Recommended Python Program of List for beginner is written below,

### 1. Write a Python program to get the largest number from a list.

l=int(input("How many numbers are you enter in your list? ")) i=1 lst=[] while i<=l: ls=int(input("enter a number ")) lst.append(ls) i+=1 print("Your list is ",lst) lst.sort() print("Largest number from your list is ",lst[-1])

Output:

How many numbers are you enter in your list? 6

enter a number 99

enter a number 88

enter a number 77

enter a number 66

enter a number 55

enter a number 44

Your list is [99, 88, 77, 66, 55, 44]

Largest number from your list is 99

### 2. Write a Python program to multiplies all the items in a list.

l=int(input("How many numbers are you enter in list? ")) i=1 lst=[] m=1 while i<=l: ls=int(input("enter a number ")) lst.append(ls) i+=1 print("Your list is ",lst) for i in lst: m=m*i print("multiplication of all the items from your list is ",m)

Output:

How many numbers are you enter in list? 5

enter a number 6

enter a number 2

enter a number 1

enter a number 7

enter a number 3

Your list is [6, 2, 1, 7, 3]

multiplication of all the items from your list is 252

### 3. Write a Python program to get the second largest number from a list.

l=int(input("How many numbers are you enter in list? ")) i=1 lst=[] while i<=l: ls=int(input("enter a number ")) lst.append(ls) i+=1 print("Your list is ",lst) lst.sort() lst.remove(lst[-1]) print("Second Largest number from your list is ",lst[-1])

Output:

How many numbers are you enter in list? 7

enter a number 55

enter a number 2

enter a number 0

enter a number 88

enter a number 11

enter a number 999

enter a number 5

Your list is [55, 2, 0, 88, 11, 999, 5]

Second Largest number from your list is 88

### 4. Write a program to remove all the duplicate elements from list.

l=int(input("How many numbers are you enter? ")) i=1 lst=[] while i<=l: ls=int(input("enter a number ")) lst.append(ls) i+=1 print("Your list is ",lst) dup=[] for i in lst: if i not in dup: dup.append(i) print("Your list without duplicate value is ",dup)

Output:

How many numbers are you enter? 9

enter a number 4

enter a number 7

enter a number 0

enter a number 4

enter a number 5

enter a number 1

enter a number 5

enter a number 7

enter a number 33

Your list is [4, 7, 0, 4, 5, 1, 5, 7, 33]

Your list without duplicate value is [4, 7, 0, 5, 1, 33]

### 5. Write a Python program to count the number of strings where the string length is 4 or more and the first and last character are same from a given list of strings.

l=int(input("How many numbers are you enter in list? ")) i=1 lst=[] while i<=l: ls=(input("enter a string: ")) lst.append(ls) i+=1 print("Your list is ",lst) c=0 for i in lst: if len(i)>=4: if i[0]==i[-1]: c+=1 print("number of strings where the string length is 4 or more and the first and last character are same from a given list of strings is: \n",c)

Output:

How many numbers are you enter in list? 6

enter a string: madam

enter a string: I'm

enter a string: python

enter a string: lover

enter a string: naman

enter a string: aka

Your list is ['madam', "I'm", 'python', 'lover', 'naman', 'aka']

number of strings where the string length is 4 or more and the first and last character are same from a given list of strings is:

2

### 6. Write a Python program to find common items from two lists.

l=int(input("How many numbers are you enter in 1st list? ")) i=1 lst=[] while i<=l: ls=(input("enter a number ")) lst.append(ls) i+=1 print("Your 1st list is ",lst) lst2=[] k=1 l2=int(input("How many numbers are you enter in 2nd list? ")) while k<=l2: ls=(input("enter a number ")) lst2.append(ls) k+=1 print("Your 2nd list is ",lst2) lst3=[] for j in lst: if j in lst2: lst3.append(j) print("common items from both lists is ",lst3)

Output:

How many numbers are you enter in 1st list? 4

enter a number madam

enter a number python

enter a number naman

enter a number world

Your 1st list is ['madam', 'python', 'naman', 'world']

How many numbers are you enter in 2nd list? 5

enter a number list

enter a number program

enter a number madam

enter a number world

enter a number sir

Your 2nd list is ['list', 'program', 'madam', 'world', 'sir']

common items from both lists is ['madam', 'world']

### 7. Write a Python program to find the list in a list of lists whose sum of elements is the highest.

l=int(input("How many numbers in list? ")) i=1 j=1 lst=[] for i in range(l): slst = [] sl = int(input("How many numbers in sublist? ")) for j in range(sl): ls=int(input("enter a number ")) slst.append(ls) j+=1 lst.append(slst) i+=1 print("Your sublist is ", slst) print("Your list is ",lst) sm=[] for k in lst: s = 0 for m in k: s=s+m sm.append(s) i=sm.index(max(sm)) print("list of lists whose sum of elements is the highest is ",lst[i])

Output:

How many numbers in list? 4

How many numbers in sublist? 3

enter a number 55

enter a number 5

enter a number 10

Your sublist is [55, 5, 10]

How many numbers in sublist? 2

enter a number 99

enter a number 1

Your sublist is [99, 1]

How many numbers in sublist? 4

enter a number 1

enter a number 2

enter a number 3

enter a number 4

Your sublist is [1, 2, 3, 4]

How many numbers in sublist? 3

enter a number 0

enter a number 30

enter a number 5

Your sublist is [0, 30, 5]

Your list is [[55, 5, 10], [99, 1], [1, 2, 3, 4], [0, 30, 5]]

list of lists whose sum of elements is the highest is [99, 1]

I Think You Understand above Highly Recommended Python Program of List for Beginner.

For any query feel free to fill comment section and send it.

**More Topic of Python:**

Python Program of Basic Question’s Part-1

Python Program of Basic Question’s Part-2

Top Python Program of String for beginner

Mind Blowing While Loop program for beginner

## Recent Comments