Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

replace character in string python by index

## returns a matching string where every even letter is uppercase,
## and every odd letter is lowercase
def string_slicing(str_1):
    length = len(str_1)
    for x in range(0, length):
        if x % 2 != 0:
            str_1 = str_1[:x] + str_1[x].upper() + str_1[x+1:]
        else:
            str_1 = str_1[:x] + str_1[x].lower() + str_1[x+1:]
    return str_1
 
PREVIOUS NEXT
Tagged: #replace #character #string #python #index
ADD COMMENT
Topic
Name
8+9 =