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
Which is an operational process performed by AWS for data security? a.Background virus scans of EBS volumes and EBS snapshots
Tresset [83]

Answer:

B. All decommissioned magnetic storage devices are degaussed and physically destroyed in accordance with industry-standard practices.

Explanation:

6 0
3 years ago
Which component is likely to be a performance bottleneck on a workstation used to edit digital movies
rjkz [21]

Explanation:

The disk subsystem - the files will be too large to be stored completely in system memory and so must be streamed from the disk, which will need to be both large and fast.

4 0
3 years ago
Computers are not automatic they need human to operate.(true or false)​
Soloha48 [4]

Answer:

both

Explanation:

most computers need a human to operate but there are ai can run without human intervention

7 0
3 years ago
Read 2 more answers
Does anyone know what the name of the game is, where you click on the grey dots in a 3x3 grid and try to make them all the same
antoniya [11.8K]

Answer:

Its the pattern puzzle game.

Explanation:

The answer is straight forward. Its a pattern puzzle game, and here we need to change everything to same color, and that is a pattern of this pattern game. Many forms of such pattern games are available, but this one happens to be the most popular among them all, and is widely used by various people of all ages to pass their time.

3 0
3 years ago
Free point giveaway pt.10 and brainliest to first answer
g100num [7]

Answer:

3+3=6

Explanation:

Tysm!!!

8 0
3 years ago
Read 2 more answers
Other questions:
  • What is not critical when you are first designing a database?
    9·1 answer
  • The network layer, or osi layer 3, provides services to allow end devices to exchange data across the network. to accomplish thi
    15·1 answer
  • write a program that converts a Fahrenheit temperature to Celsius. The design of this program is important as I want you to brea
    14·1 answer
  • Intellectual property piracy has gotten a small boost from the increasing availability of counterfeit goods through Internet cha
    14·1 answer
  • What data type can be used to hold any single character, including numbers and non-printing characters?
    15·2 answers
  • What is an infodemic?
    10·1 answer
  • Write a print statement that displays a random integer between 5 and 5000. Assume the random library is imported.
    12·1 answer
  • Describe how serial data access finds data
    9·2 answers
  • 3. In 1989, the first handheld console was released by _____ and it was called ________.
    11·1 answer
  • Which of the following numbers is of type
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!