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
sergeinik [125]
3 years ago
13

Write a function, sublist, that takes in a list of numbers as the parameter. In the function, use a while loop to return a subli

st of the input list. The sublist should contain the same values of the original list up until it reaches the number 5 (it should not contain the number 5).
Computers and Technology
1 answer:
Alla [95]3 years ago
4 0

Answer:

Following are the code to this question:

def sublist(l):#defining a method list sublist that accepts a list

   val=[]#defining an empty list

   x=0#defining x variable that store value 0

   while(x<len(l)):#defining loop that check x is lessthen list length  

       if(l[x]==5):#defining if block that checks list value equal to 5

           break#using break keyword  

       val.append(l[x])#add value in val list

       x+= 1#increment the value of x variable by 1

   return val#return val

l=[3,4,7,8,5,3,2]#defining list l

print(sublist(l))#using print method to call sublist method

Output:

[3, 4, 7, 8]

Explanation:

  • In the above python code, a method "sublist" is declared that accepts a list, inside the method an empty list "val" and an integer variable x is defined that stores "0"  value.
  • In the method, a while loop is declared that checks list length and define if block to checklist element value equal to "5". which the condition is true it will return before values.
  • In the last step, a list "l" is declared that holds value and used the print method to call sublist to prints its return value.
You might be interested in
Writing a function that implements a loop to collect a set amount of data. The function should use the serial object, the record
Assoli18 [71]
You can still go on a date with you if I get a text from my friend that is in a relationship and you don’t know why
4 0
3 years ago
I recorded a video on my windows PC, but when i tried to play it i got this message:
Anit [1.1K]

Answer:

yes. Look up popular video repair sites and download it (unless its online) but dont just go clicking on random things you dont want to give yourself a virus XD

Explanation:

7 0
2 years ago
Read 2 more answers
How to become a web developer ?​
statuscvo [17]

Explanation:

1.By Learning web development Fundamentals.

2.Choose a development specialization.

5 0
3 years ago
Why is removing presentation-oriented markup from one's html document considered to be a best practice?
Gelneren [198K]

Answer

Its for the purpose of  maintenance and readability

Explanation

A presentation-oriented markup web application generates interactive web pages containing various types of markup language.

Markup is a language designed for the purposes of processing definition and presentation. It specifies code for formatting, both the layout and style, within a text file. Markup describes the structure while the styling is how it looks. it uses the code to specify the formatting which are called tags.

3 0
3 years ago
Which font style is said to be slightly above the other line of text?
Keith_Richards [23]
I think the answer would be "superscript"
8 0
3 years ago
Read 2 more answers
Other questions:
  • Where is authorization management app on tablet?
    7·1 answer
  • A hard drive that is running slowly may not have been
    10·2 answers
  • What did basic elements of music look like in the Twentieth Century period?
    6·1 answer
  • What arw two reasons for maintaning your privacy on the internet
    11·2 answers
  • As a consommé simmers, the meat and eggs coagulate, forming a
    6·1 answer
  • Which statement is not true? An audit objective for systems maintenance is to detect unauthorized access to application database
    8·1 answer
  • Linda has written a program that works well on various operating systems, but she needs to increase the readability of the progr
    14·1 answer
  • Can anyone fill in the space please
    6·1 answer
  • Which of the following is not true?A. An organization may express its cybersecurity state through a Current Profile to report re
    10·1 answer
  • Gus has decided to organize his inbox on June 26 by using folders and deleting irrelevant messages. He creates a folder called "
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!