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
Give an example of a language L such that |L|=5 and |L^2|=16.
Basile [38]

Answer:

He can define pas follows: Let P be defined on the set of languages accepted by some Turing machine M. Let it be True if 10 ] is 5 and False otherwise.  

Explanation:

The domain of P is the SD languages since it is those languages that are accepted by some Turing machine H. P is nontrivial since P({ a, aa, aaa, aaaa, aaaaa, aaaaaa, b, bb, bbb, bbbb, bbbbb, bbbbbb } ) is True and P ( 5 ) is False.  

Thus {< M> is a Turing machine and I L I - 5 and  I L I - 16 }

7 0
2 years ago
Ken is a mobile app developer. He is designing a mobile app that offers tips and guidance to people interested in learning jazz
Luden [163]

Answer:

D is the one that makes the most sense

3 0
3 years ago
Read 2 more answers
Technician A says that OBDI and OBDII use different DLC connectors. Technician B says that OBDII standardizes the designations f
Ivenika [448]

Answer:

The answer is "Technician B"

Explanation:

The OBDII is a standardized, automated framework which the USA EPA had approved and installed into its whole year of modeling (MY) 1996 and then into modern light-duty vehicles and trucks, recognized as "on-board diagnostics II."  

  • The DTC framework is a set of problematic diagnostic codes that used alert you if a vehicle is unable to operate using an on-board Diagnostic System.
  • If the system of the automobile identifies a problem, a special DTC code is generated as well as a position sensor is sent to the instrument cluster, that's why Technician B is correct.
8 0
3 years ago
What leadership style involves the ideas of advice others
makvit [3.9K]
Democrat good luck dude
5 0
3 years ago
How are &lt; embed &gt; tags used in web page creation?
yKpoI14uk [10]

Answer:

The <embed> HTML element embeds external content at the specified point in the document. This content is provided by an external application or other source of interactive content such as a browser plug-in.

Explanation:

7 0
2 years ago
Other questions:
  • Jack wants to store a large amount of data on his computer. He chooses to use a database for this purpose. What is a database? A
    8·1 answer
  • Text, numbers,graphics, sounds entered into a computer's memory during input operations are referred to as
    11·1 answer
  • . What may happen if a large number of computer users are attempting to access a Web site at the same
    10·2 answers
  • THE DOMAIN IN AN EMAIL MESSAGE TELLS YOU THE
    11·1 answer
  • The answer for this question?
    14·1 answer
  • The business case for using grid computing involves all of the following except: speed of computation. cost savings. agility. in
    5·1 answer
  • The company database may be stored on a central database server and managed by a database adminstrator true or false
    12·1 answer
  • While software vendors generally provide evaluation or demonstration copies of their products, hardware vendors never provide ev
    15·1 answer
  • A user contacted the help desk to report that the laser printer in his department is wrinkling the paper when printed. The user
    5·1 answer
  • A cover letter should simply restate what is included in your résumé.<br> True<br> False
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!