Python takes the upper and lower elements of an element in list

how do I get the upper and lower elements of an element in list? Thank you for your advice.

Mar.23,2021

if you are using the index to locate the element, such as l [I] , you should be able to get it via l [item1] , l [I-1] . If not, you can get the index first and then through the index.


if positioned by this element, pre, last = l [l.index (a)-1], l [l.index (a) + 1]

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3711f-2c047.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3711f-2c047.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?