Skip to content
Advertisement

.strip() on array using for loop in Python not working?

I’m trying to get rid of blankspace before and after an element in an array using .strip(), How do i get this to work correctly, I currently have :

JavaScript

my output which is nearly right, but still has a space before the second element is:

JavaScript

Advertisement

Answer

I believe you are stripping before splitting. You want to split before stripping.

JavaScript

Output:

JavaScript

Also, ing1 could probably be a string.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement