Skip to content

Instantly share code, notes, and snippets.

@nwoow
Created May 11, 2020 14:52
Show Gist options
  • Select an option

  • Save nwoow/6501190a532cce761fb5ff4875532215 to your computer and use it in GitHub Desktop.

Select an option

Save nwoow/6501190a532cce761fb5ff4875532215 to your computer and use it in GitHub Desktop.
string = "height"
def getRhymePattern(string):
vowel= ["a","e","i","o","u"]
new_vowel = "y"
first_letter = 0
last_letter = len(string)-1
substring = []
values_key = []
y_vowel = False
contigous_number = []
for i in range(len(string)):
# Check if y value is in first and lst index of string Start
if new_vowel == string[i]:
if i == first_letter or i == last_letter:
y_vowel = True
# Check if y value is in first and lst index of string End
for j in range(len(vowel)):
if string[i] == vowel[j]:
values_key.append({"key": i,"value": string[i]})
# Check if vowels are contegious Start
number_check_repeat = []
for x in range(len(values_key)):
number_check_repeat.append(values_key[x]["key"])
# print(values_key[x]["key"])
last_vowel = values_key[len(values_key)-1]["key"]
first_vowel = values_key[0]["key"]
# Check if vowels are contegious End
# check if array repeats
real_number = 0
number_check_repeat_add = 0
for i in range(len(number_check_repeat)):
real_number = number_check_repeat[i] + i
number_check_repeat_add += number_check_repeat[i]
# check if array repeats Starts
repeat_value = False
if real_number == number_check_repeat_add:
repeat_value = True
# check if array repeats Ends
resut_array = []
if repeat_value:
for item in range(first_vowel,len(string)):
resut_array.append(string[item])
else:
for item in range(last_vowel,len(string)):
resut_array.append(string[item])
return resut_array
getRhymePattern(string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment