+ 2
[Solved] Where is the difference?
Sorry, if this is a newbie question but why does this code work: import string astring=str(input()) for i in astring: if i not in string.ascii_letters and i not in string.digits and i != " ": #Do something .. and this code not: import string astring=str(input()) for i in astring: if i not in [string.ascii_letters, string.digits, " "]: #Do something Any suggestions how to shorten the task more?
2 Antworten
+ 9
You need to concatenate the lists.
For example,
list1 + list2 + list3
+ 4
so easy, thank you ..
it is really an easy way:
for i in astring:
if i not in (string.ascii_letters + string.digits + " "):