Write a program that takes a list as input and outputs the last element of that list. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Write a program that takes a list as input and outputs the last element of that list.

it is a code coach problem and i m totally unable understand this question can anyone give me some hint.. to solve this

22nd Feb 2021, 6:48 AM
Rahul Prasad
Rahul Prasad - avatar
6 Answers
+ 1
yes actually i did not the syntax to print last element thanks for your help
22nd Feb 2021, 9:27 AM
Rahul Prasad
Rahul Prasad - avatar
+ 1
print(elements[::-1][0])
22nd Jul 2021, 2:48 PM
ABC Py
0
actually question is to make list and i was unable to understand to do this
22nd Feb 2021, 7:02 AM
Rahul Prasad
Rahul Prasad - avatar
0
and it is the first step so how can i show my try
22nd Feb 2021, 7:03 AM
Rahul Prasad
Rahul Prasad - avatar
0
l = list(input()) print(l[-1]) You will get better answer, if you show your attempt to the community.Hope it help.
22nd Feb 2021, 8:52 AM
བསོད་ནམ་བཀྲ་ཤིས།
བསོད་ནམ་བཀྲ་ཤིས། - avatar
0
#trythis x = input() elements = x.split() print(elements[-1])
9th Oct 2021, 10:46 PM
Fragile Fox
Fragile Fox - avatar