Where in my code do I make this new slice of new_word?


#1

Question

Where in my code do I make this new slice of new_word?

Answer

A common issue here is trying to replace what we already had for new_word, where we concatenated word, first, and pyg. For this exercise we should change new_word again, but by assigning a value over it using the existing version of itself. Take a look at the example below for a better idea:

my_word = first + middle + suffix
my_word = my_word[index_to_slice_goes_here]

Otherwise, we’d be writing new_word = new_word[...] without having defined new_word yet, which will give you an error that reads: NameError: ‘new_word’ is not defined because we’re trying to use it to define itself, which is invalid.


FAQ: Learn Python - Pyglatin - Ending Up
#2

2 posts were split to a new topic: This Code Seems Counter-Intuitive


#3

in the terminal for Pyglatin
i type Love
and it shows velay
how it’s executed


#4

There is space between I love you so is.alpha doest not count the space so it would not execute so you could use or insted of and . Even you could add the ASCII code of the characters


#5

Why can’t I declare the three variables we declared inside the if statement outside of it? What would happen?


#6

technically you could, but why would you? You only want to do these steps when the user input is valid (which the if condition is checking)