Activity 2 Functions
Thu Mar 07 2024 03:13:25 GMT+0000 (Coordinated Universal Time)
Saved by
@jerichobongay
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)")
content_copyCOPY
Comments