0

Python (check example, please): is it correct to use for not in var? What can be an alternative to achieve same result?

Example: var = "abc" for c not in var: print (a)

22nd Apr 2020, 2:35 PM
Alex Soroiu
Alex Soroiu - avatar
4 Antworten
+ 2
It's an error... When you use not in, in a for loop... There's nothing to print...
22nd Apr 2020, 2:51 PM
sarada lakshmi
sarada lakshmi - avatar
+ 1
First tell me, what the output should be?
22nd Apr 2020, 2:54 PM
sarada lakshmi
sarada lakshmi - avatar
+ 1
Okay, solved. I wanted to get a text input from the user and to eliminate any character that was not a number from the text. So I have just introduced inside for loop an "if c not in" and I managed to get the result. Thank you!!
22nd Apr 2020, 2:56 PM
Alex Soroiu
Alex Soroiu - avatar
0
And is there any form to do it?
22nd Apr 2020, 2:52 PM
Alex Soroiu
Alex Soroiu - avatar