Python, split user input twice. At pair and space

Basic String manipulation.
There are lots of tutorials out there on that, go look them up.

From your question, it looks like you would want to use the isalpha() builtin.

Here’s a function that should do the string manipulation like you said.

def pair(user):
    user=user.split(" ")
    for x in range(len(user)):
        print ("\nPair part "+str(x)+":")
        for char in user[x]:
            if char.isalpha():
                print ("Alphabet: "+char)
            else:
                print ("Number: "+char)

then you can call it with:

print("example pair was 'A1 KW'")
pair("A1 KW")
pair(input("\nEnter your pair: "))

output:
example pair was ‘A1 KW’

Pair part 0:
Alphabet: A
Number: 1

Pair part 1:
Alphabet: K
Alphabet: W

Enter your pair: AB 3F

Pair part 0:
Alphabet: A
Alphabet: B

Pair part 1:
Number: 3
Alphabet: F

Leave a Comment