I'm trying to figure out how to edit the below to have a option to convert lower/upper(abc = ABC) I'd like to have a specific input that it knows to convert to the other. so input might be "convert_upper" the program now knows I want to convert the next input "abc" into " 'A', 'B', 'C' "
I've made it pretty far into this endeavor through forums but figuring out how to get the input1 to take a "special request" and do upper/lower based on that input has thrown me for loop Also I was curious how I can create the list. (a 2nd input that confirms the name for the list something like . . . )
example in/output^
input1 = numbers
numbers = []
input2 = 123
numbers = ['1', '2', '3']
current code takes input such as "abc 123 !@#" and outputs a list ['a', 'b', 'c', ' ', '1', '2', '3', ' ', '!', '@', '#']
def split(word):
return list(input1)
input1 = input("enter Letters, Numbers or Symbols: ")
print(split(input1))
Here's one approach: have a function that you apply to the input, and check for "special requests" to change it:
special_requests = {
"convert_upper": str.upper,
"convert_lower": str.lower,
"vanilla": str
}
func = str
while True:
i = input("? ")
if i in special_requests:
func = special_requests[i]
else:
print(func(i))
? abc123
abc123
? convert_upper
? abc123
ABC123