In: Computer Science
>>> flipSwitches( ['A','A','a','B'] )
{'B'}
>>> flipSwitches( 'ABCba')
{'C'}
>>> flipSwitches( 'sdfjSDSDFasjjfdjldsSDF' )=={'S', 'D', 'F'}
True
use python 3.7
Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks
#code
#required method
def flipSwitches(switches):
    #initializing an empty set to store switches
that are on
    on_switches=set()
    #looping through each element/character in
switches
    for i in
switches:
        #checking if i is
uppercase or lowercase
        if
i.isupper():
           
#simply adding i to on_switches. note that since on_switches is
a set,
           
#we dont have to worry about duplicates as duplicates are not
allowed
           
#in sets
           
on_switches.add(i)
        elif
i.islower():
           
#converting i to upper case
           
i=i.upper()
           
#if i is in on_switches, removing it, meaning turning switch i
off
           
if i in on_switches:
               
on_switches.remove(i)
    #at the end, returning on_switches set
    return
on_switches