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
lisabon 2012 [21]
4 years ago
13

The function below takes a single string parameter: sentence. Complete the function to return a list of strings that are in the

sentence that contain a lowercase letter 'a'. Hint: you may find the split method and in operator useful in solving this problem.

Computers and Technology
1 answer:
trasher [3.6K]4 years ago
4 0

Answer:

#section 1

def listofWordswitha(text):

   ''' This function prints out every word in a string with the letter 'a' '''

   tex = text.split()

   new = []

#section 2

   for word in tex:

       for char in word:

           if char == 'a':

               new.append(word)

               

               break

   return new

Explanation:

#section 1

You must first define your function and give it one argument that represents the the string that you will pass to it.

It is always good to have a doc-string that tells you what a function does, so i have also included one.

Next, you split the string using the split method that creates a list out of a string. Finally in this section you create a new list that will hold all the values with 'a'.

#section 2

The choice of words used here are intentional to make it easy to understand.

FOR every WORD in the list and FOR every CHARACTER in the WORD.

IF there is a CHARACTER 'a' contained in the word, ADD that WORD to the NEW LIST.

the append method is used to add new words to the list.

A break is used to ensure we don't have any duplication because some words can have two or more occurrence of 'a' in them. so whenever the loop sees a word with 'a', it appends it and moves to the next word.

Lastly, we return the new list.

I will take your question and use it to test the code and attach the results for you.

You might be interested in
What does usb stand for
e-lub [12.9K]
Universal Serial Bus
8 0
3 years ago
Read 2 more answers
During early recording, microphones picked up sound waves and turned them into electrical signals that carved a _______ into the
Tcecarenko [31]

Answer:

Groove

Explanation:

There is not much to explain

8 0
3 years ago
Within a major students can choose to study a specific area within major. For example a journalism student may study military jo
crimeas [40]

Answer:

Specialization

Hope this helps!

6 0
4 years ago
Instead of delivering songs that you are likely enjoy services such as offers you a bility to play practically song that you wan
s344n2d4d5 [400]
Use Amazon music you can play any song you want
7 0
4 years ago
Which of the following is the correct way for writing JavaScript array?
Ostrovityanka [42]
<h3>\large\bold{\underline{\underline{Answer :-}}}</h3>

<h3> C. var salaries = new Array(39438,39839,83729) </h3>

8 0
2 years ago
Read 2 more answers
Other questions:
  • Sasha has decided to start a consulting business. She will need space for large meetings and a receptionist. Which of the follow
    14·1 answer
  • What is a relationship between a object and a class?
    6·1 answer
  • The file manager used in Microsoft Windows is
    11·1 answer
  • How can I use internet if data is turned off​
    5·2 answers
  • 2. Write a program with a function that accepts a string as an argument and returns a copy of the string with the first characte
    11·1 answer
  • How many keys are utilized in symmetric cryptography?A. OneB. TwoC. ThreeD. Four
    10·1 answer
  • A new school is being built in the local school district.It will have three computer labs with 28 computers each. There will be
    13·1 answer
  • Think of a genre (science, music, math, sports, video games, etc.) and create at least 10 questions. You can decide whether you
    12·2 answers
  • PowerPoint Online automatically saves your presentation to what Office Online application? OneDocument OneDrive OneNote OneWay
    13·2 answers
  • The term used to describe whereby old and new media are available via the integration of personal computers and high speed satel
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!