Ask coding questions

← Back to all posts
Why does this not work
Alebot33 (0)

def cube(num):
return numnumnum
def square(num):
return num*num

a = input("What would you like to do? (Cube or square): ")
x = input("Tell me a number now: ")

if str(a.lower) == square:
elif str(a.lower) == cube:
print(a + " is not a valid answer")

Coder100 (16855)
  1. It is already a string
  2. You need quotations. Those are functions not strings.
if a.lower() == 'square':
LegendaryWolf (626)

give me the link to your project(copy-paste the link in address bar of ur repl)

Alebot33 (0)

@LegendaryWolf its not a project im just messing around, but when I put for example cube and 3 it says cube is not a valid answer

LegendaryWolf (626)

I just don't understand the code coz there is no syntax highlighting and indenting pls invite me to your repl