if you run your code in a console (after adding the missing bracket) you will see that it executes at least once, before the user is asked to input. Then there is really only 2 choices. Either the number they input is less than equal to 10, in which case the loop will continue, or if they enter any number greater than 10, the loop will stop.
So given that the user always enter a number smaller than or equal to 10 it would basically make the second part of the while statement (y <= 10) always true and then it only matters what the first statement comes to (x <= 3). And this statement has been determined by your code, so there is no uncertainty. This means that the code will execute a maximum of 3 times (because that’s how it’s been programmed) but it may be fewer, if the user enters a number greater than 10, which would end the loop immediately.
Its my first time here, so I hope I am writing in the proper place and not bothering anyone!!
Here is my question, and thank you for reading!!
Its an activity from the Python 3 beginners course. I’ve been for a while trying to understand why I don’t get the result I should in the second function call, the “Hello world” one. Any hint about why ¿?
In the first function call I get “Cdcdm” but in the second one I get “Hlloworld”
Thanks for the help!
Write your every_other_letter function here:
def every_other_letter(word):
other = “”
for letter in word:
if word.find(letter)%2 == 0:
other += letter
return other
Uncomment these function calls to test your function:
You might have an indentation error, but it’s difficult to tell b/c your code isn’t formatted. If you could please format your code by using the “</>” button above, that would be helpful.
Please see here on that.
Going forward, this is a good guide to check out before posting. It’s under the “New User Guide” on the home page:
That said, remember that spaces also have an index value. And, .find() finds the first index value of the occurrence.