+ 1
How do you remove things that are not letters or numbers
Using the remove function
4 Answers
+ 1
x="@#213anas45%&+"
y=''
for i in x:
if i.isalpha() or i.isdigit():
y+=i
print(y)
+ 1
Using the functional programming, the filter function accepts two arguments
: function
: iterable
So, in a string X, you can filter your result R as
X = "hks12%"
R = list(filter(lambda x:x.isalnum(), X))
print(*R)
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.