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
prisoha [69]
3 years ago
10

Write a function swap that swaps the first and last elements of a list argument. Sample output with input: 'all,good,things,must

,end,here' ['here', 'good', 'things', 'must', 'end', 'all']
Computers and Technology
2 answers:
asambeis [7]3 years ago
8 0

Answer:

def swap(li):

   n=len(li)

   li[0],li[n-1]=li[n-1],li[0]

   return li

Explanation:

Python is very user friendly language and and this provides numerous functions and in-built services. In the above function, i have created a method which is taking an argument li and we can find the length of li by using method len() which is then stored in variable n. Now we have to swap first and last element so, first element of li is li[0] and last is li[n-1]. Python provides one more utility in which we can change values of 2 elements simultaneously by separating them with comma. So, we put the value of last element in first and value of first in last which saved many lines of code.

zubka84 [21]3 years ago
7 0

Answer:

li=list(map(str,input().strip().split()))#taking input of the string.

#swapping first and last element.

temp=li[0]

li[0]=li[-1]

li[-1]=temp

print(li)#printing the list.

Explanation:

I have taken the list li for taking the input of strings.Then after that swapping first and last element of the list.Then printing the list.

You might be interested in
HELP PLX ITS PYTHON BTW!!!
ExtremeBDS [4]

Answer:

Sebastian is your last name diaz

Explanation:

Functions allow us to break our program into multiple parts

Multiple is the answer

Atlanta-Robinson

5 0
3 years ago
Who was making the high-pitched growling noise that Francisco hears?
Gwar [14]

The high-pitched growling noise that Francisco hears is due to mating call of male midshipman fish or 5G.

<h3>What is the  hum about?</h3>

The Hum is known to be a kind of unexplained happenings that has brought a lot of irritations to people. It is known to be a high-pitched noise that brought a lot of scientific theories.

Studies has shown that the high-pitched growling noise that Francisco hears is as a result of  mating call of male midshipman fish or 5G.

Learn more about noise from

brainly.com/question/2278957

8 0
2 years ago
Explain four features of presentation packages​
hichkok12 [17]
You have add more for anyone to be able to answer this, sorry
4 0
2 years ago
Computer spreadsheet is a grid of​
Kruka [31]
Huh we’re, we’re is the computer screen shot
3 0
3 years ago
Which type of operating system requires a keyboard in order to issue commands?
kicyunya [14]

Answer:

I said CLI.

Explanation:

''A command-line interface (CLI) processes commands to a computer program in the form of lines of text.''- Wikipedia

4 0
3 years ago
Other questions:
  • What are personal skills? A manner of individual style How a person manages and expresses oneself One's ability to excel at spor
    13·2 answers
  • Which of these computers was marketed as a computer/game machine?
    15·2 answers
  • Which computer network component allows data transfers from one computer to another through a telephone line?
    11·2 answers
  • On the pie chart below, which “slice” represents 30% of the budget?
    8·1 answer
  • What is a computer briage coures​
    15·1 answer
  • Your program is going to compare the distinct salaries of two individuals for the last 5 years. If the salary for the two indivi
    15·1 answer
  • A _______ area network is a type of wireless network that works within your immediate surroundings to connect cell phones to hea
    9·2 answers
  • The font color grid is located in the color group on the design tab. (points : 2) true false
    9·1 answer
  • What are 25 items that trees made?
    6·2 answers
  • Ways to be your best digital self?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!