1
나는 this을 보았지만 아무런 도움이되지 않았습니다.문자열의 크기를 찾으려고 할 때 오류가 발생했습니다
game = 1
while game == 1:
print('WORLD EVALUATOR 2000')
word = input("Insert some text...").lower()
words = word.split(" ")
lastWord = words[-1]
if word[0].lower() in 'aeiou':
print("The string begins with a vowel")
elif word[0].lower() in '1234567890':
print ("The string begins with a number")
elif word[0].lower() in 'bcdfghjklmnpqrstvwxyz':
print ("The string begins with a consonant")
elif word[0].lower() in '[email protected]#$%^&*()_+{}|:"<>?':
print ("The string begins with a symbol or a space.")
elif word[0].lower() in ' ':
print ("The string begins with a space.")
else:
print("The string does not begin with a vowel,number, consonant, space, or a symbol")
if word[1].lower() in 'aeiou':
print("The string's second letter is a vowel")
elif word[1].lower() in '1234567890':
print ("The string's second letter is a number")
elif word[1].lower() in 'bcdfghjklmnpqrstvwxyz':
print ("The string's second letter is a consonant")
elif word[1].lower() in '[email protected]#$%^&*()_+{}|:"<>?':
print ("The string's second letter is a symbol or a space.")
elif word[1].lower() in ' ':
print ("The string's second letter is a space.")
else:
print("The string's second letter is not a vowel,number, consonant, space, or a symbol")
if lastWord[-1].lower() in 'aeiou':
print("The string's last letter is a vowel")
elif lastWord[-1].lower() in '1234567890':
print("The string's last letter is a number")
elif lastWord[-1].lower() in 'bcdfghjklmnpqrstvwxyz':
print("The string's last letter is a consonant")
elif lastWord[-1].lower() in '[email protected]#$%^&*()_+{}|:"<>?':
print("The string's last letter is a symbol or a space.")
elif lastWord[-1].lower() in ' ':
print("The string's last letter is a space.")
else:
print("The string's last letter is not a vowel,number, consonant, or a symbol")
print("The string is " + str(len(words)) + ' letters/numbers/symbols long.')
끝 부분에는 len을 사용하지만 작동하지 않는 부분이 있습니다. 도움이 될만한가요?
누군가가 묻는다면, stackoverflow의 형식이 나를 미워하기 때문에 while 루프가 적절히 들여 쓰기되지 않습니다. 실제로 루프는 len 부분에 대해 잘 작동합니다.
내가 그냥 "1" – CatsInSpace
세계 평가자 2000 일부 텍스트를 삽입 말한다 출력을 얻을 ... Absosc 는 문자열 문자열의 두 번째 문자가 문자열의 마지막 문자가있는 자음 이다 모음으로 시작 자음 문자열은 1 글자/숫자/기호입니다. – CatsInSpace
당신은 문자가 아닌 단어의 수를 세고있다 –