+ 1

How do you remove things that are not letters or numbers

Using the remove function

28th Apr 2021, 4:38 PM
dalton mutugi
dalton mutugi - avatar
4 Respostas
+ 1
x="@#213anas45%&+" y='' for i in x: if i.isalpha() or i.isdigit(): y+=i print(y)
28th Apr 2021, 6:05 PM
Shadoff
Shadoff - avatar
0
By using the index of the element. Syntax: del <List_name>[<index>] or del <List_name>[<start>:<stop>] May this will help you.
28th Apr 2021, 4:54 PM
Aman Jain
Aman Jain - avatar
0
If you wanna solve your problem in O(n) then run a loop in which each iteration check if a character lands in an alphanumeric category(not underscore)or not, otherwise pop it.
28th Apr 2021, 4:56 PM
Rahul Saxena
Rahul Saxena - avatar