Skip to content

Explanation to this question  #4019

@EliKanevski

Description

@EliKanevski

• This question concerns the processing of lists and strings.
• Create a list of strings ls word as follows.

  1. Write a loop and in the loop, prompt the user to enter a line of text from the console.
  2. Read the input text into a string s.
  3. Split the string s and set ls word to the resulting list.
  4. Use the default action to perform the split, i.e. items are separated by spaces.
  5. If you do your work correctly, ls word will contain strings without whitespaces.
  6. Break out of the loop if the list ls word has at least four elements, else prompt again

Am I supposed to have my list without any whitespace? Prompt 3 & 4 seem to contradict. Can someone's explain this please?
(Professor won't explain)
Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions