Freddy has a really fat left pinky finger, and every time Freddy tries to type an ```A```, he accidentally hits the CapsLock key!

Given a string that Freddy wants to type, emulate the keyboard misses where each ```A``` supposedly pressed is replaced with CapsLock, and return the string that Freddy actually types. It doesn't matter if the ```A``` in the string is capitalized or not. When CapsLock is enabled, capitalization is reversed, but punctuation is not affected.

Examples:

```
"The quick brown fox jumps over the lazy dog."
-> "The quick brown fox jumps over the lZY DOG."

"The end of the institution, maintenance, and administration of government, is to secure the existence of the body politic, to protect it, and to furnish the individuals who compose it with the power of enjoying in safety and tranquillity their natural rights, and the blessings of life: and whenever these great objects are not obtained, the people have a right to alter the government, and to take measures necessary for their safety, prosperity and happiness."
-> "The end of the institution, mINTENnce, ND dministrTION OF GOVERNMENT, IS TO SECURE THE EXISTENCE OF THE BODY POLITIC, TO PROTECT IT, nd to furnish the individuLS WHO COMPOSE IT WITH THE POWER OF ENJOYING IN Sfety ND TRnquillity their nTURl rights, ND THE BLESSINGS OF LIFE: nd whenever these greT OBJECTS re not obtINED, THE PEOPLE Hve  RIGHT TO lter the government, ND TO Tke meSURES NECESSry for their sFETY, PROSPERITY nd hPPINESS."

"aAaaaaAaaaAAaAa"
-> ""
```

**Note!**

If (Caps Lock is Enabled) and then you (HOLD Shift + alpha character) it will always be the reverse

Examples:
```
(Caps Lock Enabled) + (HOLD Shift + Press 'b') = b
(Caps Lock Disabled) + (HOLD Shift + Press 'b') = B
```

If the given string is `""`, the answer should be evident.

Happy coding!

~~~if:fortran
*NOTE: In Fortran, your returned string is* **not** *permitted to contain any unnecessary leading/trailing whitespace.*
~~~


(Adapted from https://codegolf.stackexchange.com/questions/158132/no-a-just-caps-lock)

Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code:
def fat_fingers(string):
	

Solutions:
def fat_fingers(s):
	if not s:
		return s
	swap = [False]
	return ''.join((c.swapcase() if swap[0] else c for c in s if c not in 'aA' or swap.__setitem__(0, not swap[0])))


import re

def fat_fingers(string):
	return ''.join((w.swapcase() if i % 2 else w for (i, w) in enumerate(re.split('a|A', string))))


import re
fat_fingers = lambda s: s and re.sub('[aA](.*?)(a|A|$)', lambda m: m[1].swapcase(), s)


from itertools import cycle

def fat_fingers(s):

	def characters(s):
		it = cycle([str, str.swapcase])
		f = next(it)
		for c in s:
			if c in 'aA':
				f = next(it)
			else:
				yield f(c)
	return ''.join(characters(s))


def fat_fingers(string):
	if type(string) != str:
		return string
	(aCnt, chars) = (0, [])
	for c in string:
		if c in 'aA':
			aCnt += 1
		else:
			chars.append(c.swapcase()) if aCnt & 1 else chars.append(c)
	return ''.join(chars)


def fat_fingers(string):
	if string is None:
		return None
	tokens = string.replace('a', 'A').split(sep='A')
	for (i, token) in enumerate(tokens):
		if i % 2 == 0:
			continue
		tokens[i] = token.swapcase()
	return ''.join(tokens)


def fat_fingers(string):
	if string is None:
		return None
	ret = []
	capslock = False
	for c in string:
		if c in 'aA':
			capslock = not capslock
		else:
			ret.append(c.swapcase() if capslock else c)
	return ''.join(ret)


def fat_fingers(string):
	fat_string = ''
	count = 0
	for i in string:
		if i == 'a' or i == 'A':
			fat_string += ''
			count += 1
		elif count % 2 == 1 and i.upper() == i:
			fat_string += i.lower()
		elif count % 2 == 1 and i.lower() == i:
			fat_string += i.upper()
		else:
			fat_string += i
	return fat_string


def fat_fingers(string):
	if string == '':
		return string
	if string is None:
		return None
	new_string = ''
	caps_lock = False
	for l in string:
		if l.isalpha():
			if l.lower() == 'a':
				caps_lock = not caps_lock
			elif caps_lock and l.lower() == l:
				new_string += l.upper()
			elif caps_lock and l.upper() == l:
				new_string += l.lower()
			else:
				new_string += l
		else:
			new_string += l
	return new_string