Skip to content

Instantly share code, notes, and snippets.

View RaMSFT's full-sized avatar

RaMS Nelluri RaMSFT

View GitHub Profile
def decrypt_shift_right(decode_str):
"""Decode the given string (a step up the alphabest)
a -> c
b -> d
...
k -> m
o -> q
e -> g
..
z -> b
def decrypt_shift_right_trans(decode_str):
"""Decode the given string (a step up the alphabest)
a -> c
b -> d
...
k -> m
o -> q
e -> g
..
z -> b
def encrypt_shift_left_trans(decode_str):
"""encode the given string (a step down to next alphabest)
a <- c
b <- d
...
k <- m
o <- q
e <- g
..
z <- b
def encrypt_shift_left(decode_str):
"""encode the given string (a step down to next alphabest)
a <- c
b <- d
...
k <- m
o <- q
e <- g
..
z <- b
def check_elemnt_in_list(input_list, value):
if value in input_list:
return f"Given value: {value} exists in the list"
else:
return f"Given value: {value} doesn't exists in the list"
print(check_elemnt_in_list(["hi", "edabit", "fgh", "abc"], 'fgh'))
print(check_elemnt_in_list(["Red", "blue", "Blue", "Green"], 'blue'))
print(check_elemnt_in_list(["a", "g", "y", "d"], 'd'))
def find_element_with_index(input_list, index_value):
try:
return f"Element value: {input_list[index_value]} at the index: {index_value}"
except:
return f"no element exists at the index {index_value}"
print(find_element_with_index(["hi", "edabit", "fgh", "abc"], 1))
print(find_element_with_index(["Red", "blue", "Blue", "Green"], 2))
print(find_element_with_index(["a", "g", "y", "d"], 10))
def find_index(input_list, search_str):
try:
val = input_list.index(search_str)
return f"index of {search_str} is {val}"
except:
return f"index of {search_str} is not found"
def find_index(input_list, search_str):
for val in range(0, len(input_list)):
if input_list[val] == search_str:
return f"index of {search_str} is {val}"
return f"index of {search_str} is not found"
print(find_index(["hi", "edabit", "fgh", "abc"], 'fgh'))
def string_to_list(split_str):
result_list = list(split_str)
return result_list
print(string_to_list('Hello This is Python'))
print(string_to_list('Python'))
print(string_to_list('Edabit'))
def list_to_string(lst):
#Given list might contain numerics also, hence, convert each element into the string
#This can be done with loops also, using map to do it here
str_list = list(map(str, lst))
#Using join to add all elements together into a string
result_str = ''.join(str_list)
return result_str