Write a Python function that shifts the character of strings


Topic: Write a Python function that shifts the character of strings

Solution

def char_shift(string, shift_count):
    '''This function takes a string as an input and shifts each character by 5 and returns shifted string'''
    return "".join([chr(ord(x)+shift_count) if (ord(x)+shift_count) <= 122 else chr(96 + (ord(x)+shift_count) - 122) for x in string])



List all Python Programs