Wat did i do wrong? The solution was as shown. Here my screenshot. Please help.
Your else is too soon - best to save it for a catchall at the end of all your ifs. Removing the else from your code will leave 3 ifs, which should work fine.
We should use the variable value to print the contents which are not rope. I find no instructions as to how to embed the variable value in the print statement. “A” variable "is not useful right now "???
Hey folks! I’ve managed to finish the final mountain-related task. Is there a way that I could have my else statement use the name of the equipment item in the print statement?
I’m trying to get it to work in a manner where it’ll output something like:
“This compass is of no use to you”
Thanks in advance for any help you can offer.
Also, does my code look ok? I have the niggling feeling that I’ve missed something even though the app passed me.
Good point! We don’t explicitly teach how to combine a string and a variable’s value, but it is in several puzzles (such as Math Modifier). This comment from another thread may be useful, in short: you can use the
+ symbol to combine a variable and a string, for example:
print(element + ' is not useful right now')
Hope this helps!
I have to put “A” first before the element variable. The program keeps introducing backslashes for me behind the inner single quotes.
OK Thanks, all fixed. I’d stick in a screen shot but I don’t know how.
Looks like you’ve got an extra
element === 'rope' at the top of your for loop that isn’t needed. If you remove that are you able to solve the puzzle?
thank you i reslove it
bueno la solución fue mas fácil de lo que esperaba. gracias grasshopper…
Looks like you have an extra if statement inside your else block, as well as an extra
element = 'rope' at the top of your for loop. Have a look at @Venkat_Sudheer_Reddy’s screenshot to get an idea of what the solution can look like.
So do I have to add if else statement
I trying to do this lesson. …but It is not successful. …please help me to fix this code
Please show me to what is the wrong of code. …
Looks like you’ve just got one small issue: an extra line of code at the very top of your for loop block.
The line of code
element === 'rope' (before the if statements) isn’t doing anything and is unnecessary code. Try removing it and your solution should work!
What's wrong with my code?