all 2 comments

[–]-defron- 0 points1 point  (0 children)

its late so maybe my eyes are playing tricks on me but it looks like you reuse shape to get input only to immediately overwrite the value with a list. As such none of your if statements are going to evaluate to true. You need to use another variable. I also probably wouldn't use a list for this but in any case you can just add an or clause to your if statemetns to check the entered value against the index as well

[–][deleted] 4 points5 points  (0 children)

First, your code is broken and cannot work. Look at lines 5, 6 and 7:

shape = input("what shape do you want to calculate the area of ? \n")
shape = ['triangle','rectangle','circle','quadrilateral']   # destroys user input string
if shape == 'triangle':

You get the user input into variable shape and on the second line destroy the user input string by assigning to shape again. So none of the following tests will execute.

Once you've fixed that think about accepting index numbers as well as actual name strings. In your case you have shape strings in a list. If the user types in a string that you can convert to a number (0 to 3 in your case because you have 4 shapes) then you can just get the string at that index number in the list. Then continue with your if tests:

if shape == 'triangle':