Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics Types and Branching If, Else and Elif

help me please

print("hello, and welcome to choose your own adventure. ") print("you wake up on a deserted island with no memories. across the island there are zombies so be careful.") print("it is growing dark and you are hungry ") answer = input(' choice one, there are palm trees on one side of the island you can go search for coconuts.') answer = input(" choice two, on the other side of the island there are a pack of wild boar you can try to kill one,") if answer == choice one.

runfile('/Users/sarahgyampoh/untitled3.py', wdir='/Users/sarahgyampoh') File "/Users/sarahgyampoh/untitled3.py", line 13 if answer == choice one ^ SyntaxError: invalid syntax

2 Answers

Hi Sarah, to show the code use the following markdown: Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting.

      (```)html
      <p>This is code!</p>
      (```)

without the parentesis. And try to format your code to make it more readable, like this:

print("hello, and welcome to choose your own adventure. ")
print("you wake up on a deserted island with no memories. across the island there are zombies so be careful.") 
print("it is growing dark and you are hungry ") 
answer = input(' choice one, there are palm trees on one side of the island you can go search for coconuts.') 
answer = input(" choice two, on the other side of the island there are a pack of wild boar you can try to kill one,")
if answer == choice one.

I think something is missing, can you please copy & paste all your code?

Ryan Markey
seal-mask
.a{fill-rule:evenodd;}techdegree
Ryan Markey
Front End Web Development Techdegree Student 12,565 Points
print("you wake up on a deserted island with no memories.\nAcross the island there are zombies so be careful.\n") 
print("it is growing dark and you are hungry...\n\n\n") 

answer = input('First Choice, there are palm trees on one side of the island you can go search for coconuts.\nSecond Choice, on the other side of the island there are a pack of wild boar you can try to kill one.\nWhat will you do? First Choice or Second Choice...   ')


if answer.upper() == "FIRST CHOICE":
    print("You have chosen the first choice!")
else:
    print("You have chosen the second choice!")

Is this what you're trying to do?

From what I can understand from your code...

The 'input' method returns a string, a string that the user enters themselves, so the 'answer' variable will need to store either "first choice" or "second choice" for the game to work. You only need one 'input' method.

The 'if' statement then checks the 'answer' variable for either 'first choice' or 'second choice'.

Remember that 'if' statements need to be formatted like this:

if (condition):
    <run this code>

Don't forget the ' : ' colon, after the condition!