This is my first post so please give me feedback on how I can format my future questions. I am having trouble understanding this code I recently found. Could someone explain this code segment to me and how it works? I had trouble finding it on Google.
def iterate(sequence: str) -> str: # <- What does (variable: type) -> type do?
sequence = sequence+R+swapLetters(sequence[::-1])
return sequence
def swapLetters(sequence: str) -> str: # <- What does (variable: type) -> type do?
newSequence = ""
for letter in sequence:
if letter == R:
newSequence = newSequence + L
else:
newSequence = newSequence + R
return newSequence
def dragon(n_iterations: int) -> str: # <- What does (variable: type) -> type do?
initial_sequence = R
for i in range(0, n_iterations):
initial_sequence = iterate(initial_sequence)
return initial_sequence
I am talking about the parameter in all of the functions.