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
morpeh [17]
3 years ago
13

Question 3 (8 marks): Write a program that takes a string from the user and splits it into a list using a space (" ") as the del

imiter. Do not use split(). Print the result. Hints: Use a for loop to loop through the string. Keep track of the index of the last part of the string that you "split". When you reach a space, you know to split again. Use string slicing to get the portion of the string that you want.
Computers and Technology
1 answer:
bonufazy [111]3 years ago
5 0

Answer:

In Python:

mystr = input("Sentence: ")

mylist = []

word = ""

for i in range(len(mystr)):

   if not i == len(mystr)-1:

       if not mystr[i] == " ":

           word+=mystr[i]

       else:

           mylist.append(word)

           word = ""

   else:

       word+=mystr[i]

       mylist.append(word)

print(mylist)

Explanation:

Prompt the user for an input sentence

mystr = input("Sentence: ")

Initialize an empty list

mylist = []

Initialize each word to an empty string

word = ""

Iterates through the input sentence

for i in range(len(mystr)):

If index is not the last, the following if condition is executed

   if not i == len(mystr)-1:

If the current character is not space

       if not mystr[i] == " ":

Append the character to word

           word+=mystr[i]

If otherwise

       else:

Append word to the list

           mylist.append(word)

Set word to an empty string

           word = ""

If otherwise; i.e. If index is not the last

   else:

Append the last character to word

       word+=mystr[i]

Append word to the list

       mylist.append(word)

Print the list

print(mylist)

You might be interested in
Sara is a college student studying accounting. She uses a laptop daily for personal and course work. What data might Sara have o
polet [3.4K]

Answer:

Sara: Personal data

Jorge : Personal data + official data.

Wanda: Personal data + students data

Carl: Personal data + official data

Explanation:

Personal data could contain pictures, social security numbers, banking transactions details, passwords, credit card information etc.

Jorge's official data could contain information about various sources that he gets his news from. It could contain password information about his official email. And he connects to the office network, he might pose a threat to the entire network if his PC is infected.

Wanda could leak the student's information. She could also leak her social security numbers, bank details, organization's details etc.

Carl could leak company's information. He can avoid it by staying away from public networks. Installing anti-virus. He should also take great care while accessing various sites and never download harmful files over the internet.

8 0
3 years ago
What are the components that make a computer work?
Schach [20]

Answer: Plastic, metal, rubber, wiring, electricity, technology, wifi,  

Explanation: You need  PLASTIC to make a frame for the computer. METAL

to make an exoskeleton under the plastic frame. RUBBER to hold those loose wires and to make sure the electricity doesn't escape and shock you. ELECTRICITY to charge and make the computer runs.  Technology is used for you to log in and out of your computer and WIFI to make sure it doesn't lag.

8 0
3 years ago
A vector is based on...​
Vaselesa [24]

Answer:

Magnitude and direction

Explanation:

Vector quantity is a quantity which is described by magnitude and direction

8 0
4 years ago
Choose the answer.
expeople1 [14]

There are no options can u give options.

4 0
3 years ago
Who here watches obx, Riverdale or on my block?
melomori [17]

Answer:

Riverdale i watch it!

Explanation:

3 0
2 years ago
Read 2 more answers
Other questions:
  • In microsoft word, when you highlight existing text you want to replace, you’re in
    14·1 answer
  • What are the names of each devices pleaseee​
    13·2 answers
  • What is the Kali Linux's kernel?<br><br> Sorry for english, but help me.
    12·1 answer
  • Choose a project with a relatively simple description (building a LAN, designing a web page, inventing a new communication devic
    6·1 answer
  • Advancements in nuclear science have led to technological advances which are both harmful and beneficial. Which would be conside
    15·1 answer
  • What is theory of knowledge?​
    13·1 answer
  • Drag each label to the correct location on the image. Match the movie qualities with the right period of movies.
    8·1 answer
  • What tool can help discover and report computer errors when you first turn on a computer and before the operating system is laun
    9·2 answers
  • Which of the following statements is NOT
    15·1 answer
  • Identify a statement that accurately differentiates between short-term memory and working memory.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!