import pandas as pd
def analyze_string(s):
words = s.split()
data = []
for i, word in enumerate(words, 1):
word_data = {
"word": word.strip(",.",
"len": len(word.strip(",."),
"vowels": "".join(
sorted(set([c.lower() for c in word if c.lower() in "aeuioy"]))
),
"symbols": any([not c.isalpha() for c in word]),
}
data.append(word_data)
return pd.DataFrame(
data, index=["word{}".format(i) for i in range(1, len(data) + 1)]
)
s = input()
result = analyze_string(s)
print(result)
при вводе 10 fingers, 10 toes, 2 eyes And a round nose.
выводит
word len vowels symbols
word1 10 2 True
word2 fingers, 8 ei True
word3 10 2 True
word4 toes, 5 eo True
word5 2 1 True
word6 eyes 4 ey False
word7 And 3 a False
word8 a 1 a False
word9 round 5 ou False
word10 nose 4 eo True
nose должен выводиться с точкой соответственно len должен быть 5
def analyze_string(s):
words = s.split()
data = []
for i, word in enumerate(words, 1):
word_data = {
"word": word.strip(",.",
"len": len(word.strip(",."),
"vowels": "".join(
sorted(set([c.lower() for c in word if c.lower() in "aeuioy"]))
),
"symbols": any([not c.isalpha() for c in word]),
}
data.append(word_data)
return pd.DataFrame(
data, index=["word{}".format(i) for i in range(1, len(data) + 1)]
)
s = input()
result = analyze_string(s)
print(result)
при вводе 10 fingers, 10 toes, 2 eyes And a round nose.
выводит
word len vowels symbols
word1 10 2 True
word2 fingers, 8 ei True
word3 10 2 True
word4 toes, 5 eo True
word5 2 1 True
word6 eyes 4 ey False
word7 And 3 a False
word8 a 1 a False
word9 round 5 ou False
word10 nose 4 eo True
nose должен выводиться с точкой соответственно len должен быть 5