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:
print(square(x))
elif str(a.lower) == cube:
print(cube(n))
else:
print(a + " is not a valid answer")

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

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 (574)

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