Share
Get the output | R Interview Question | Zomato
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
TDM = [‘The’,’Data’,’Monk]
a. Print the last object of the list
b. Change the last element to Monkey
c. Remove Monkey from the list
d. GET Monk back to the list
They did not use The Data Monk as example 😛
Answer ( 1 )
Solution in Python:
TDM = [‘The’,’Data’,’Monk’] #List
#to display the last element
print(TDM[2])
Output: ‘Monk’
#to change the last element to Monkey
TDM[2] = ‘Monkey’
Output: [‘The’, ‘Data’, ‘Monkey’]
#to remove Monkey from the list
TDM.remove(‘Monkey’)
Output: [‘The’, ‘Data’]
#to get Monk back to the list
TDM.append(‘Monk’)
print(TDM)
Output: [‘The’, ‘Data’, ‘Monk’]