[Tutor] Python help
Alan Gauld
alan.gauld at yahoo.co.uk
Sun Oct 16 20:19:42 EDT 2016
On 15/10/16 23:48, Nicholas Hopkins wrote:
> Please tell me what is wrong with my code and how I can put an if else statement
> inside of another if else statement
You are almost right but...
> This is my code:
> path = input('Which path number will you take?')
> if path == '1':
> print('You took the first path')
> elif path == '2':
> print('You choose to take the second path')
> print('You see a rock')
> rock == input('Do you want to pick up the rock')
indentation is important in Python and the above line
should line up with the one above it. You should have
gotten an Indentation Error message.
> if rock == 'yes':
> print('you picked up the rock')
> else:
> print('You left the rock')
And if this clause lined up correctly too then it would
work as you expected.
> elif path == '3':
> print('You choose to take the third path')
> else:
> print('You must choose a number between 1 and 3')
>
>
> it comes up with this error
> [cid:image001.png at 01D22792.63CCF290]
Please include the error in your message. This is a text
only list and attachments tend to get stripped off
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list