i am trying to solve a problem where i want to classify string and int separately. My question is when user input anything then my program find all words(str) and int separately.
Like user input "wert1234" then it should print "string is wert" and int are 1234"
I tried with many ways but i am facing problem i tried with :
in=input()
for i in in:
if type(i)==type(str):
print(i)
but its not working i also tried with regex :
import re
df=input()
regex = r"([a-zA-Z]+) \d+"
matches = re.findall(regex, df)
for match in matches:
print(match)
stri = r"([0-9]+) \d+"
search=re.findall(ret,df)
for j in search:
print(j)
so i have two question:
first please tell how i can classify string and int differently if input is mix ?
second question is how search only int with regex? like if user input "wer 123" so regex search only 123 and print.