Your problem is that you have put your code into functions, but never call them.

When you define a function:

def shape():
    ...

To run that code, you then need to call the function:

shape()

Note that Python runs code in order - so you need to define the function before you call it.

Also note that to call a function you always need the brackets, even if you are not passing any arguments, so:

if shape == 1: rectangle

Will do nothing. You want rectangle().

Answer from Gareth Latty on Stack Overflow
Discussions

What's wrong with my code (python beginner)
You’re printing the function without including a value for the parameter. You could try something like print(grade_value(grade)) or you can store the returned value into a variable and then print the variable. More on reddit.com
🌐 r/learnprogramming
69
358
September 20, 2021
Correcting my code
Hey guys, i am having trouble correcting my code for this question Input 7 positive numbers and make each number negative. Then add the negative number to a list. Print the list of negative numbers in the reverse order it was entered. Print the word “End” before the program ends. i have ... More on discuss.python.org
🌐 discuss.python.org
0
1
April 30, 2023
Errors with my python code - Stack Overflow
My python cod keeps giving me errors like indention and syntax which I keep fixing them but to no avail. So here is the code I'm using I'm still not sure what I'm doing wrong here (BTW this is just... More on stackoverflow.com
🌐 stackoverflow.com
What is wrong with this Python code? - Stack Overflow
Can anyone tell me what is wrong with this? I'm getting a syntax error after the 2nd quote on the print line... It seems like this should work perfectly fine. Thanks def main(): print "blah... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Python.org
discuss.python.org › python help
Help! what's wrong with my code? - Python Help - Discussions on Python.org
May 15, 2024 - Hi everyone, I’m a beginner at Python and taking an online course. I submitted a task like below but the system always said it was wrong. Would anyone help me to check what is wrong? I checked 3 times but I still have no…
🌐
Toptal
toptal.com › python › top-10-mistakes-that-python-programmers-make
The 10 Most Common Python Code Mistakes | Toptal®
May 31, 2023 - As a result, in the above example, at the point that __del__ is invoked, the name foo has already been set to None. A solution to this somewhat more advanced Python programming problem would be to use atexit.register() instead. That way, when your program is finished executing (when exiting normally, that is), your registered handlers are kicked off before the interpreter is shut down. With that understanding, a fix for the above mod.py code ...
🌐
Reddit
reddit.com › r/learnprogramming › what's wrong with my code (python beginner)
r/learnprogramming on Reddit: What's wrong with my code (python beginner)
September 20, 2021 -

I started coding about two weeks ago and began writing some code to take in user input in the form of a letter grade and return a value, but when I tried out the code in terminal it just printed out <function grade_value at 0x7fa6831d1f70>. I would like for it to return the value of the grade.

# values for letter grades
A = 20
B = 17.5
C = 15
D = 12.5
E = 10
F = 0

# user grade
grade = input('your grade: ')
grade = str(grade)


# returns user grade value as int
def grade_value(user_grade):
    if user_grade == 'A':
        return A
    elif user_grade == 'B':
        return B
    elif user_grade == 'C':
        return C
    elif user_grade == 'D':
        return D
    elif user_grade == 'E':
        return E
    elif user_grade == 'F':
        return F
    else:
        return('error')


# call function and print value (just testing)
grade_value(grade)
print(grade_value)
🌐
Python.org
discuss.python.org › python help
Correcting my code - Python Help - Discussions on Python.org
April 30, 2023 - Hey guys, i am having trouble correcting my code for this question Input 7 positive numbers and make each number negative. Then add the negative number to a list. Print the list of negative numbers in the reverse order it was entered.
🌐
freeCodeCamp
freecodecamp.org › news › common-errors-in-python-and-how-to-fix-them
Common Errors in Python and How to Fix Them
December 11, 2025 - In this example, we misspelled the variable name my_variable as my_vairable. ... Another common error in Python is type errors. Type errors occur when you try to perform an operation on data of the wrong type. For example, you might try to add a string and a number, or you might try to access an attribute of an object that doesn't exist. ... Use type annotations in your code ...
Find elsewhere
🌐
Better Stack
betterstack.com › community › guides › scaling-python › python-errors
15 Common Errors in Python and How to Fix Them | Better Stack Community
January 27, 2026 - For example, trying to divide a string with an integer: ... Traceback (most recent call last): File "/home/stanley/code_samples/main.py", line 1, in <module> print("hello" / 3) TypeError: unsupported operand type(s) for /: 'str' and 'int' This ...
🌐
Codecademy
codecademy.com › forum_questions › 55cb3aa99376768e4800042e
What is wrong with my Python code | Codecademy
So, this is my code: pyg = ‘ay’ original = raw_input(‘Enter a word:’) word = original.lower() first = word[0] if len(original) > 0 and original.isalpha(): print first else: print ‘empty’ · This is my error message: File “python”, line 6 print first ^ IndentationError: expected an indented block
🌐
Sololearn
sololearn.com › en › Discuss › 2039436 › what-is-wrong-with-this-python-code
What is wrong with this python code? | Sololearn: Learn to code for FREE!
I am a beginner. I ran this code on Jupyter notebook and VS code but it showed an 'unknown syntax error' in line 5. Then went to code playground on sololearn and it work
🌐
Sololearn
sololearn.com › en › Discuss › 2981796 › what-is-wrong-with-my-python-code
What is wrong with my python code , | Sololearn: Learn to code for FREE!
Hy .My task was to get the name and age and write " Name + " is " + age + " years old " " but something went wrong . My code : name = input() age = int(input()) syr =
🌐
freeCodeCamp
forum.freecodecamp.org › python
What is wrong with my python code? - Python - The freeCodeCamp Forum
December 27, 2019 - Hello. I want to write code for sequences below but it doesn’t work. WHat is wrong ? Could you help me Code is; import math def un(n_terms): def vn(n_terms): p = 0 sum_un = 0 while n_terms>=1: whi…
🌐
Python.org
discuss.python.org › python help
What is wrong with my code? - Python Help - Discussions on Python.org
August 13, 2020 - import math as m import numpy as py x=‘Hii Dude’ print(x.center(60)) print() x=‘Do u need any help’ print(x.center(60)) x=input('answer (yes/no) : ') print() y=‘yes’ l=‘no’ if x==y: q='Okay choose from given options' print(q.center(60)) print("\n1 : Square of a number \n2 : Cube of a number \n3 : Power of a number \n4 : Square root of a number \n5 : Odd numbers between a and b\n6 : Even numbers between a and b\n7 : Prime numbers between a and b\n8 : Greatest intege...
🌐
Stack Overflow
stackoverflow.com › questions › 69963197 › why-is-my-python-code-giving-wrong-answers-for-only-some-inputs
Why is my python code giving wrong answers for only some inputs? - Stack Overflow
I don't think you need to map the input to list of str as input() always returns a string and string itself is a list of characters. Also make sure you don't use the built-ins as your variable names (As str used in your code).
🌐
ExtendsClass
extendsclass.com › python-tester.html
Python Code Checker - Online syntax check
If a syntax error is detected, then the line in error is highlighted, and it jumps to it to save time (no need to search the line). It can be useful to make online test to save time (deployment ...). Note: This tool no longer offers sandbox, it was not good enough.