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
3. Rajat wants to assign green colour to a paragraph. Write the code that will help him in completing the task
coldgirl [10]

Explanation:

use the style attribute

4 0
2 years ago
Historia da inteligencia artificial
choli [55]

Answer:

hshdhwvevwuwijwvww

Explanation:

wwgwvisgwgqiwieoiw

5 0
2 years ago
Read 2 more answers
While a threat intelligence analyst was researching an indicator of compromise on a search engine, the web proxy generated an al
inna [77]

Answer: the corret answer C. The analyst has prefetch enabled on the browser in use.

Explanation:

The analyst has like an indicator which is prefetch enabled on the browser in use.

7 0
2 years ago
What is the use of an NDP?
Makovka662 [10]

Answer:

It defines five ICMPv6 packet types for router solicitation,router advertisement,neighbor solicitation,neighbor advertisement,and network redirects.

Explanation:

8 0
2 years ago
How does the medium affect the amplitude of sound?
Ratling [72]

The amplitude of a sound energy depends upon the how much energy we are giving to the wave or how much compression on the wave is taking place.

It does’t depends upon the wave length,frequency


7 0
2 years ago
Other questions:
  • An engine's _______ contains the cylinder block, the cylinders, the piston, the connecting rods, and the crankshaft assemblies.
    9·2 answers
  • Identify the function for the following computer part: Printer Question 23 options: Input
    6·1 answer
  • You run an automobile selling company that has a popular online store on AWS. The application sits behind an Auto Scaling group
    6·1 answer
  • Describe some advantages of a 64-bit versus 32-bit version of windows.
    9·1 answer
  • This program will get you used to retrieving a value from a function. The function should be named getRandomNumber. The function
    15·1 answer
  • Advantages of heading attributes
    5·1 answer
  • In order to install a device, the operating system needs the required __________ for that device.
    13·2 answers
  • When a computer or digital device is used as a storage device or in the facilitation of an offense, it is argued to be ____ to t
    14·1 answer
  • PLEASE I NEED HELP FAST
    8·1 answer
  • William brought some data into his Tableau Book, but the data had some null values and incorrect column headers. What did Willia
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!