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
murzikaleks [220]
3 years ago
11

#Write a function called alter_list. alter_list should have#two parameters: a list of strings and a list of integers.##The list

of integers will represent indices for the list of#strings. alter_list should alter the capitalization of all#the words at the designated indices. If the word was all#capitals, it should become all lower case. If it was all#lower case, it should become all capitals. You may assume#that the words will already be all-caps or all-lower case.##For example:## string_list = ["hello", "WORLD", "HOW", "are", "you"]# index_list = [0, 2]# alter_list(string_list, index_list) -> # ["HELLO", "WORLD", "how", "are", "you"]##After calling alter_list, the strings at indices 0 and 2#have switched their capitalization. ##Note that it may be the case that the same index is present#in the second twice. If this happens, you should switch the#text at that index twice. For example:## string_list = ["hello", "WORLD", "HOW", "are", "you"]# index_list = [0, 2, 2]# alter_list(string_list, index_list) -> # ["HELLO", "WORLD", "HOW", "are", "you"]##2 is in index_list twice, so the string at index 2 is#switched twice: capitals to lower case, then back to#capitals.#Write your function here!#Below are some lines of code that will test your function.#You can change the value of the variable(s) to test your#function with different inputs.##If your function works correctly, this will originally#print:#["hello", "WORLD", "HOW", "are", "you"]#["HELLO", "WORLD", "HOW", "are", "you"]print(alter_list(["hello", "WORLD", "HOW", "are", "you"], [0, 2]))print(alter_list(["hello", "WORLD", "HOW", "are", "you"], [0, 2, 2]))
Computers and Technology
1 answer:
Aleks04 [339]3 years ago
7 0

Answer:

The Python code is given below with appropriate comments

Explanation:

def alter_list(strings,index):

   

   for i in index:

       s = strings[i]

       if s.islower():  #checking if lowercase

           strings[i] = s.upper()  #assigning variable in strings to uppercase in s

           

       if s.isupper():  #checking if uppercase

           strings[i] = s.lower()  #assigning variable in strings to lowercase in s

   return strings  #returns strings for the function

           

print(alter_list(["hello", "WORLD", "HOW", "are", "you"], [0, 2]))

print(alter_list(["hello", "WORLD", "HOW", "are", "you"], [0, 2, 2]))

You might be interested in
Often, a single source does not contain the data needed to draw a conclusion. It may be necessary to combine data from a variety
nlexa [21]

To measure the pollution of a particular river, one must take the sample of the river and take the sample of pure water, then draw the conclusion, it will tell the amount of pollution in the river water.

<h3>What is pollution?</h3>

Pollution is the mixing of unwanted or harmful things in any substance or compound.

Water pollution is the mixing of toxics and chemicals in water.

Thus, to measure the pollution of a particular river, one must take the sample of the river and take the sample of pure water, then draw the conclusion, it will tell the amount of pollution in the river water.

Learn more about pollution

brainly.com/question/23857736

#SPJ1

6 0
2 years ago
In a _error,solution is working but not giving required results
drek231 [11]

Answer:

<h2>it is a random error </h2>

Explanation:

<h3>I HOPE THAT THIS ANSWER HELPS YOU </h3>
7 0
2 years ago
The FCFS algorithm is particularly troublesome for ____________.
Nina [5.8K]

Answer:

The correct option is (b) multiprogramming systems

The best I can explain: In a time sharing system, each user needs to get a share of the.... at regular intervals.

Explanation:

Don't forget to follow me thanks

8 0
2 years ago
If Number = 7, what will be displayed after code corresponding to the following pseudocode is run? (In the answer options, new l
kherson [118]

Answer:

5,10; 6,12; 7,14

Explanation:

We will demonstrate the iteration of the loop:

First iteration: Number = 7, Count = 5 at the beginning. We will check if Count <= Number? Since it is correct, prints 5,10. Increment the Count by 1.

Second iteration: Number = 7, Count = 6. We will check if Count <= Number? Since it is correct, prints 6,12. Increment the Count by 1.

Third iteration: Number = 7, Count = 7. We will check if Count <= Number? Since it is correct, prints 7,14. Increment the Count by 1.

Forth iteration: Number = 7, Count = 8. We will check if Count <= Number? Since it is not correct, the loop stops.

8 0
3 years ago
People who enjoy working with their hands might enjoy a career as an
Kaylis [27]
People that enjoy working with their hands might enjoy being a construction worker but their are a lot of other jobs that involve using their hands but being a construction worker takes a lot of effort and a lot of hard work to complete.
6 0
3 years ago
Read 2 more answers
Other questions:
  • Assume the following representation for a floating point number 1 sign bit, 4 bits exponent, 3 bits for the significand, and a b
    9·1 answer
  • Write a program that allows a user to input words at the command line. Your program should stop accepting words when the user en
    10·1 answer
  • The rod and crankshaft convert the up-and-down motion of the piston into
    12·2 answers
  • Weber believed that there is an inevitable destructive quality to which one of the four types of action?
    8·1 answer
  • 1. Create a detail report that will display all SCR courses in alphabetical order, with the course name and the instructor name
    6·1 answer
  • A user reports that she can't access the new server used in the accounting department. you check the problem and find out that h
    9·1 answer
  • A wide variety of apps are available to customize devices, which category of app does word processing software falls into?
    10·1 answer
  • To find out how much ram is installed on a machine, in windows go to the user: a power ______ is a part inside a computer case t
    6·1 answer
  • What are advantages of using document templates?
    13·2 answers
  • In a well-developed paragraph - using domain-specific vocabulary and academic writing - address the following writing prompt:
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!