Python Forum

Full Version: Printing strings.. help..
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
My first defined function works, however I can't get my second defined function to work. I need my main function to access the upperCase function and then print everything in all caps. For example the user enters in hi, I need my program to convert that to HI. For the love of god I can't figure out where I am going wrong. Can anybody show me? Thanks.

Also, how can I get my program to run nonstop? I'm kind of new with looping. 



def reverse(text):
    rev_text = ""
    for i in text:
        rev_text = i + rev_text
    return rev_text


def upperCase(text1):
    text1 = s.upper()
    return text1


def main():
    
    text = str(input("Enter a text: "))
    print(reverse(text))

    text1 = str(input("Enter a number again: "))
    print(upperCase(text1))


main()
string splicing and string methods
>>> 'reverse'[::-1]
'esrever'
>>> 'uppercase'.upper()
'UPPERCASE'
loop
while True:
    #do something repetitive ie. your code here
    if condition to quit:
        break
My program works, please tell me what you think and if I should change anything?


def reverse(text):
    return text[::-1]

def upperCase(text2):
    return text2.upper()

def hyphens(text3):
    return '-'.join(text3.split())

def main():

    while True:
        text = str(input("Enter a text: "))
        print(reverse(text))

        text2 = str(input("Enter another text: "))
        print(upperCase(text2))

        text3 = str(input("Enter another text: "))
        print(hyphens(text3))
        
    while False:
        break
    
main()
while False:
    break
That does nothing.  False will never be True, so the block never runs, and even if it did, all it would do would be to immediately break out of the block, which... does nothing.