Your work is to write a method that takes a value and an index, and returns the value with the bit at given index flipped.

The bits are numbered from the least significant bit (index 1).

Example:
```python
flip_bit(15, 4) == 7 # 15 in binary is 1111, after flipping 4th bit, it becomes 0111, i.e. 7
flip_bit(15, 5) == 31 # 15 in binary is 1111, 5th bit is 0, after flipping, it becomes 11111, i.e., 31
```
Note : index number can be out of number's range : e.g number is 3 (it has 2 bits) and index number is 8(for C# this number is up to 31) -> result will be 131 

See more examples in test classes

Good luck!

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def flip_bit(value, bit_index):
	

Solutions:
def flip_bit(value, bit_index):
	return value ^ 1 << bit_index - 1


flip_bit = lambda n, k: n ^ 1 << k - 1


def flip_bit(v, b):
	return 1 << b - 1 ^ v


flip_bit = lambda v, i: int(''.join([l if 64 - i != k else '0' if l == '1' else '1' for (k, l) in enumerate(('0' * 64 + bin(v)[2:])[-64:])]), 2)


def flip_bit(v, i):
	v = list(bin(v)[2:].rjust(i, '0')[::-1])
	v[i - 1] = str(1 - int(v[i - 1]))
	return int(''.join(v[::-1]), 2)


def flip_bit(value, bit_index):
	bs = list(bin(value)[2:].zfill(bit_index))
	i = len(bs) - bit_index
	bs[i] = '10'[int(bs[i])]
	return int(''.join(bs), 2)


def flip_bit(value, bit_index):
	bits = list(map(int, bin(value)[2:]))
	while len(bits) < bit_index:
		bits.insert(0, 0)
	bits[len(bits) - bit_index] ^= 1
	return int(''.join(map(str, bits)), 2)


def flip_bit(value, bit_index):
	binary = bin(value)[2:]
	if bit_index <= len(binary):
		lst = list(binary)
		lst[-bit_index] = '0' if binary[-bit_index] == '1' else '1'
		return int(''.join(lst), 2)
	return value + 2 ** (bit_index - 1)


def flip_bit(v, b):
	k = list(bin(v)[2:].zfill(b))
	k[-b] = str(1 - int(k[-b]))
	return int(''.join(k), 2)