def reverse_string(word): reversed_word = "" for char in word: reversed_word = char + reversed_word reversed_word_caps = reversed_word.upper() string_count = len(word) return reversed_word, reversed_word_caps, string_count #Get user input user_input = input("Enter a word: ") #Call the function to reverse the string reversed_word, reversed_word_caps, string_count = reverse_string(user_input) #Display the result print(f"INPUT: {user_input}") print(f"OUTPUT: {reversed_word_caps} ({string_count} characters)")
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter