Python Forum
Python uppercase conversion conditions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python uppercase conversion conditions
#1
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!

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))
Reply


Messages In This Thread
Python uppercase conversion conditions - by Jaypeng - Apr-29-2020, 06:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I need to add data types to cython conversion python to c Good_AI_User 1 1,035 Aug-19-2022, 07:52 AM
Last Post: Gribouillis
  AttributeError: module 'string' has no attribute 'uppercase' Anldra12 10 10,342 Apr-23-2021, 05:30 PM
Last Post: ibreeden
  Conversion of Oracle PL/SQL(packages, functions, procedures) to python modules. DivyaKumar 2 6,545 Jul-09-2020, 04:46 PM
Last Post: srikanth7482
  C to Python code conversion print problem anakk1n 1 2,209 May-22-2020, 04:15 PM
Last Post: deanhystad
  MATLAB to Python conversion stokd 10 5,091 Jan-19-2020, 09:14 PM
Last Post: stokd
  simple if elif conditions in Python Chandan 2 2,096 Jan-08-2020, 02:36 PM
Last Post: DeaD_EyE
  Excel Model Conversion into Python line7 2 2,282 Oct-09-2019, 07:51 AM
Last Post: line7
  macron on top of uppercase letters newbieAuggie2019 3 3,760 Aug-21-2019, 08:06 PM
Last Post: newbieAuggie2019
  python opencv grayscale conversion error Spandora 1 9,598 May-26-2019, 10:43 AM
Last Post: heiner55
  Vba conversion to Python stranger14u 1 3,606 May-26-2019, 08:01 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020