1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
amid [387]
3 years ago
15

Write an application that accepts up to 20 Strings, or fewer if the user enters the terminating value ZZZ. Store each String in

one of two lists—one list for short Strings that are 10 characters or fewer and another list for long Strings that are 11 characters or more. After data entry is complete, prompt the user to enter which type of String to display, and then output the correct list. For this exercise, you can assume that if the user does not request the list of short strings, the user wants the list of long strings. If a requested list has no Strings, output The list is empty. Prompt the user continuously until a sentinel value, ZZZ, is entered.
Computers and Technology
1 answer:
notsponge [240]3 years ago
3 0

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)

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.

You might be interested in
What is the trade-offs in time complexity between an ArrayList and a LinkedList?
AURORKA [14]

Answer:

  In the time complexity, the array-list can easily be accessible any type of element in the the given list in the fixed amount of time.

On the other hand, the linked list basically require that the list must be traversed from one position to another end position.

The Array-List can get to any component of the rundown in a similar measure of time if the file value is know, while the Linked-List requires the rundown to be crossed from one end or the other to arrive at a position.

4 0
3 years ago
Who else hates it when Edgenuity has technical problems with international students?
konstantin123 [22]

Answer: ya it sucks

AI used to be a A student until edgenuity had to be used.

Explanation:

7 0
3 years ago
Why did it take hundreds
levacccp [35]
Before that there was no way for the image to be recorded and fixed on a surface
5 0
2 years ago
When a piece of shiny silver jewelry gets tarnished, what has happened?
makvit [3.9K]
A
because if you leave certain metals in the rain they tarnish or rust. think about how if you leave a bike in the rain for too long it will start to rust on the metal parts
6 0
3 years ago
When a virtual machine is
egoroff_w [7]

Answer:

Resources, RAM

Explanation:

May be another choice for resources but the second one is definently RAM

8 0
3 years ago
Other questions:
  • Can anybody answer this for me
    13·2 answers
  • Which statement prints "hi" on the screen?
    5·2 answers
  • How to make flashcards on microsoft word 2010?
    7·1 answer
  • What is motivation and state the two forms​
    14·1 answer
  • What are some ways to find out what skills you need to develop at work? Check all of the boxes that apply.
    15·2 answers
  • Does this mechanism increase or decrease speed? Why?
    9·1 answer
  • 9.4 Code Practice: Your task is to determine whether each item in the array above is divisible
    14·1 answer
  • The purpose of __________________ is to isolate the behavior of a given component of software. It is an excellent tool for softw
    13·1 answer
  • How bridges are built over water
    14·1 answer
  • When evaluating an AND operator, what is necessary for execution?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!