+ 1

can anyone tell me the syntax to print last element of a list by list slice method

22nd Feb 2021, 8:06 AM
Rahul Prasad
Rahul Prasad - avatar
4 Answers
+ 5
print(list[-1])
22nd Feb 2021, 8:10 AM
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ - avatar
+ 2
Here is some stuff on slices https://code.sololearn.com/cXNzv56rgiyL
7th Apr 2021, 10:23 PM
David Ashton
David Ashton - avatar
+ 1
CarrieForle thanks for the help
22nd Feb 2021, 9:27 AM
Rahul Prasad
Rahul Prasad - avatar
0
Rahul Prasad sorry, but as I know slice for list is used in JavaScript. In Python, however, we use pop()! If you're talking about JS: console.log(array.slice(-1)); But if you're talking about Python : print(array.pop()) Happy programming! :)
22nd Feb 2021, 9:18 AM
TheCoder