I'm currently trying to do a program related to Python uppercase conversion conditions.
1. If the length of a word is less than 7, it is not converted.
2. If the word length is more than 7, I want to convert the first vowel to upper case.
I ran the code according to the conditions I set, and the nameerror popped up like this
NameError: name 'newword' is not defined
I've certainly defined newword, but why am I getting same error?
input example)
what a beautiful world!
output example)
what a bEautiful world!
1. If the length of a word is less than 7, it is not converted.
2. If the word length is more than 7, I want to convert the first vowel to upper case.
I ran the code according to the conditions I set, and the nameerror popped up like this
NameError: name 'newword' is not defined
I've certainly defined newword, but why am I getting same error?
input example)
what a beautiful world!
output example)
what a bEautiful world!
def Upper_Vowels(newword): sentence = input() newword = sentence.split() for i in range(len(newword)): if i >= 7 : def capital(sentence,vowel): vowels = 'aeiou' newsentence = [] for word in sentence: if word.lower() in vowels: word = word.isupper() newsentence.append(newword) return ('[]'.join(newsentence)) if "__main__" == __name__: sentence = input() print(Upper_Vowels(newword))