Answer:
count = 20
i = 0
short_strings = []
long_strings = []
while(i<count):
s = input("Enter a string: ")
if s == "ZZZ":
break
if len(s) <= 10:
short_strings.append(s)
elif len(s) >= 11:
long_strings.append(s)
i += 1
choice = input("Enter the type of list to display [short/long] ")
if choice == "short":
if len(short_strings) == 0:
print("The list is empty.")
else:
print(short_strings)
else:
if len(long_strings) == 0:
print("The list is empty.")
else:
print(long_strings)
Step-by-step explanation:
*The code is in Python.
Initialize the count, i, short_strings, and long_strings
Create a while loop that iterates 20 times.
Inside the loop:
Ask the user to enter a string. If the string is "ZZZ", stop the loop. If the length of the string is smaller than or equal to 10, add it to the short_strings. If the length of the string is greater than or equal to 11, add it to the long_strings. Increment the value of i by 1.
When the loop is done:
Ask the user to enter the list type to display.
If the user enters "short", print the short list. Otherwise, print the long_strings. Also, if the length of the chosen string is equal to 0, print that the list is empty.