+ 1
How do you remove things that are not letters or numbers
Using the remove function
3 Réponses
+ 1
x="@#213anas45%&+"
y=''
for i in x:
if i.isalpha() or i.isdigit():
y+=i
print(y)
0
By using the index of the element.
Syntax: del <List_name>[<index>]
or del <List_name>[<start>:<stop>]
May this will help you.
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.