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
🌐
Online IDE
online-ide.com › online_python_syntax_checker
Online Python Syntax Checker - OnlineIDE
OnlineIDE - Online Python Syntax Checker is a web-based tool powered by ACE code editor. This tool can be used to learn, build, run, test your programs. You can open the code from your local and continue to build using this IDE. Scripts and the results can be downloaded. ... Coding sharing option helps you to save your code in cloud so that it can be accessed anytime and anywhere with ...
Discussions

What's wrong with this python code? (beginner's question) - Stack Overflow
What is wrong with this code? I must be missing something trivial. Every time I try to run it it does nothing for a while and then outputs 'Killed'. I wanted it to take every element in list, add "... More on stackoverflow.com
🌐 stackoverflow.com
What is wrong with this Python code? (Interview Question)

Storing an integer in a variable called str is a bad idea in a weakly-typed language

While this is true that's not the problem here.

nbResults: str = 45;

this line stores an int value in a variable that's type hinted to be a str. Also semicolon is unnecessary.

More on reddit.com
🌐 r/learnpython
4
6
May 24, 2018
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 23, 2021
What is wrong with my python code?
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… More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
December 27, 2019
🌐
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…
🌐
ExtendsClass
extendsclass.com › python-tester.html
Python Code Checker - Online syntax check
Python checker allows to check your Python code syntax (Python 3), and find Python errors. This Python code checker tool highlights and goes to line with a syntax error.
🌐
Reddit
reddit.com › r/learnpython › what is wrong with this python code? (interview question)
r/learnpython on Reddit: What is wrong with this Python code? (Interview Question)
May 24, 2018 -

I've been asked this question on an interview and I'll also share what I answered.

I would like to know if there's anything I haven't thought of?

Python code:

nbResults: str = 45;

My answer was the following:

  1. Storing an integer in a variable called str is a bad idea in a weakly-typed language

  2. str is a built-in function in Python, using that name like that hides the original function

>>> str(45) '45'
>>> str=45
>>> str(45)
Traceback (most recent call last): File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable

3. Syntax is obviously wrong

  • It could have been a function call like this:

nbResults(str = 45)
  • It could have been a function with an assignment, like this:

def nbResults():
   str = 45;

Also a function with a default value for the argument, like this:

def nbResults(str = 45):
...

4. The value is wrong, it's 42, not 45. :)

Thanks for your help!

🌐
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 - As a result, Python throws an ... name 'name' is not defined · To fix this problem, ensure that the variable or function name you want to use has been defined....
Find elsewhere
🌐
Codecademy
codecademy.com › forum_questions › 55cb3aa99376768e4800042e
What is wrong with my Python code | Codecademy
It appears that you did not indent the two print statements. Because they need to be inside the if and else blocks, they both need to be indented. ... If the user enters an empty string, you should not process it.
🌐
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 23, 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)
🌐
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…
🌐
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 = " { 0} { 1} { 2 } { 3}" .format ( name , "is " , age , " years old " ) print ( syr ) ... name = input() age = int(input()) syr = "{0}{1}{2}{3}". format( name, " is " , age ," years old " ) print( syr ) ... Dzhalil Tilov I like this way a simple way name = input() age = int(input()) print (name, 'is', age, 'years old')
🌐
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 ...
🌐
Toptal
toptal.com › python › top-10-mistakes-that-python-programmers-make
The 10 Most Common Python Code Mistakes | Toptal®
May 31, 2023 - So in the above code, since the attribute x is not found in class C, it will be looked up in its base classes (only A in the above example, although Python supports multiple inheritances). In other words, C doesn’t have its own x property, independent of A. Thus, references to C.x are in fact references to A.x. This causes a Python problem unless it’s handled properly.
🌐
Stack Overflow
stackoverflow.com › questions › 32929533 › can-someone-tell-me-whats-wrong-with-my-python-code
can someone tell me what's wrong with my python code? - Stack Overflow
so this is my code, the purpose of this code is to ask the user to input an value: 1,2 or 3, if the user enter something else, it will shows "invalid input" when the user put 1,2 or 3, it will counts
🌐
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. Print the word “End” before the program ends. i have entered this code but it does not seem to work. my_list= for i in range(7): num=int(input("Enter a number: ")) my_list.append(-num) print(list(reversed(1st))) print(“End”) Would really appreciate if so...
🌐
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).