+ 1

remove and revers

how to remove and reverse, please explain with examples?

13th May 2019, 5:56 AM
Praveen Kumar Sutrave
1 ответ
0
Using you can use slicing to reverse a list or string like: string = "hello" print(string[::-1]) >>> "olleh" The same applies for lists To remove an item from a list, you can use pop() or remove() pop() removes an element by index. For example: ls = [1, 2, 3, 4, 5] ls.pop(1) >>> [1, 3, 4, 5] remove() removes an element by value. For example: ls = [1, 2, 3, 4, 5] ls.remove(1) >>> [2, 3, 4, 5] Hope this helps😁🐍
13th May 2019, 8:06 AM
Trigger
Trigger - avatar