In: Computer Science
Declare a Python list named famfri with the first names of five friends or family members.
Lists and tuples are examples of what kind of Python construct?
Write a Python for loop that prints the names of the friends or family, one per line, without referencing a range or any literal numeric values.
Write Python code examples of statements to remove the name at
position 2 from the list in the first problem, and to remove one of
the remaining names by referencing that name.
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
Question 1:
#python list
famfri=['Virat','Sachin','Rahul','John','Sam']
#using for loop printing items from list
for name in famfri:
print(name) #print name
Output :
Question 2:
Code snippet :
del famfri[2] #delete item at index 2
famfri.remove("Sam") #remove item with name as sam
Screen :
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.