This is the expected behavior. Strip will strip out of the string all the characters that you provide. You provided ., g, i, and t. All those characters got stripped out in both examples.
Return a copy of the string with the leading and trailing characters removed. The chars argument is a string specifying the set of characters to be removed.
So a_string.strip('.git') would remove all leading trailing .gi and t from the a_string. The result is therefore expected.
The simplest way to remove a .git suffix would be:
def remove_trailing_dot_git(s):
if s[-4:] == '.git':
s = s[:-4]
return s
You may also find one of str.rsplit(), str.rpartition(), or os.path.splitext() useful.