Skip to content Skip to sidebar Skip to footer

Isalpha Python Function Won't Consider Spaces

So the code below takes an input and makes sure the input consists of letters and not numbers. How would i make it also print orginal if the input contains a space original = raw_i

Solution 1:

It looks like that's just how string works.

Two options:

if all(x.isalpha() or x.isspace() for x in original):

(modified on inspectorG4dget's recommendation below)

or

original.replace(' ','').isalpha()

should work.

Post a Comment for "Isalpha Python Function Won't Consider Spaces"