14.5k views
4 votes
Write a function named spell_name that takes in a string name as parameter, and returns a list where each character in the name is an item in the list. In your main program, call this function and print the returned list.

For example:
spell_name("Jessica") should return ['J', 'e', 's', 's', 'i', 'c', 'a']


Be sure to:
include comments for all functions that you create.
validate any user inputs using try-except-else-finally and/or if-else.
validate all parameters passed to functions you write using try-except-else-finally and/or if-else.

1 Answer

4 votes

Answer:

def spell_name(s):

try:

return list(s)

except:

print("An exception occurred")

name = input('Enter your name: ')

print(spell_name(name))

Step-by-step explanation:

I wouldn't know how to trigger the exception though...

User Archit Gupta
by
7.7k points