-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListAndTuple.py
More file actions
37 lines (22 loc) · 878 Bytes
/
Copy pathListAndTuple.py
File metadata and controls
37 lines (22 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Practice Question
# Write a program to ask the user to enter names of their 3 favorite movies & store them in a list.
movies = []
movies.append(input("Enter 1st movie name :"))
movies.append(input("Enter 2nd movie name :"))
movies.append(input("Enter 3rd movie name :"))
print(movies)
# WAP to check if a list contains a palindrome of elements. (Hint: use copy() method)
list1 = [1, 2, 3, 2,1]
copy_list1 = list1.copy()
copy_list1.reverse()
if(copy_list1 == list1): # Here == is comparing the inner value only , not comparing the address ref
print("palidrome")
else:
print("NOT palidrome")
# Note : if you want to compare the address ref use ( is )
print(copy_list1 is list1)
# WAP to count the number of student with the "A" grade in the following tuple.
tup = ["C", "D", "A", "A", "B", "B", "A"]
print(tup.count("A"))
tup.sort()
print(tup)