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
Design and implement a set of classes that define various types of reading material: books, novels, magazines, technical journal
tino4ka555 [31]

Answer:

Following are the code to this question:

please find the attached file.

Explanation:

In this code, four class "novels, magazines, technical journals, and textbooks", is defined, in which it holds their respective default constructor and the get and set method to hold the string and integer value, and in the book class the main method is defined, that creates its object and a switch to for search value and print its value.

6 0
2 years ago
) Which of these will not select all the cells in a document?
dolphi86 [110]
Pressing enter two times I’m pretty sure that’s right cuz like it does nothing when I do it. It’s either that or idk up to u to take an answer from someone who has bad grammar
4 0
2 years ago
IDENTIFYING VERBS THAT AGREE IN NUMBER WITH THEIR SUBJECTS For each of the following sentences, write the correct form of the ve
Novay_Z [31]

Hey there!

  • The word "<u>verb</u>" simply means <em>'description of an action, assert, or event that is made into the main purpose of your predicate in your judgement' </em>
  • Now that we have the definition of the word verb we can answer your question
  • "<em>Has</em>" is past tense but it is THIRD person present
  • "<em>Have</em>" is when you own something
<h2>Answer: HAS ✅</h2>

BECAUSE "I SAW last night"

Note: usually people read the sentence to themselves until it makes easier sense to them or use context clues in the sentence to answer the particular question(s)

Good luck on your assignment and enjoy your day!

~LoveYourselfFirst:)

6 0
3 years ago
Read 2 more answers
What is word processing?
butalik [34]
A. Citing sources for documents you found on the web
3 0
3 years ago
Read 2 more answers
Memory is a _____________ that includes the organization and shaping of information by processing, storage, and retrieval of inf
vaieri [72.5K]

Answer:

A. <em>Encoding Process </em>

Explanation:

Memory is an <em>encoding process </em>that includes the organization and shaping of information by processing, storage, and retrieval of information.

There are two types of memory in computing, <em>RAM </em>and <em>ROM</em>. <em>RAM </em>stands for <em>Random Access Memory</em>. It I the core memory of the computer and it is especially faster regarding reading and writing process. As an analogy, RAM memory is like the “<em>Short-term</em>” memory of the computer. <em>ROM </em>stands for <em>Read-Only Memory</em>, this is the type of memory in charge of permanently storing data in the computer. It contains the necessary information to run the computer. As an analogy, <em>ROM </em>memory is like the “<em>long-term</em>” memory of the computer.

3 0
2 years ago
Other questions:
  • A(n) ____ is a collection of one or more program statements combined to perform some action
    14·1 answer
  • • Suppose Host A wants to send a large file to Host B. The path from Host A to Host B has three links, of rates R1= 500 kbps, R2
    15·1 answer
  • Small robots that can move around on the surface of a planet are called space shuttles.
    12·2 answers
  • ____ languages create source code using words and structures similar to spoken language.​
    15·1 answer
  • Advertising is organized around four distinct groups. The _____ group includes the photographers, the illustrators, video produc
    9·1 answer
  • 9.1.3: Printing vector elements with a for loop. Write a for loop to print all NUM_VALS elements of vector courseGrades, followi
    5·1 answer
  • Opportunities in nanotechnology apply broadly to many fields. Identify TWO areas of IT that may be impacted by its further devel
    6·1 answer
  • Cual
    5·1 answer
  • ________ is a utility program included with most operating systems that allows you to move or eliminate files and give your oper
    14·1 answer
  • Active directory and 389 directory server are both compatible with which directory access protocol?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!