Warum gibt meine Python-Funktion „None“ zurück, obwohl ich „return“ innerhalb der Funktion verwendet habe? [Duplikat]Python

Python-Programme
Anonymous
 Warum gibt meine Python-Funktion „None“ zurück, obwohl ich „return“ innerhalb der Funktion verwendet habe? [Duplikat]

Post by Anonymous »

Ich versuche, eine einfache Funktion in Python zu schreiben, die die Fläche eines Quadrats berechnet, aber die Funktion gibt den Wert aus, anstatt ihn zurückzugeben. Wenn ich versuche, das Ergebnis zu speichern, erhalte ich None.

Code: Select all

def area_of_square(side):
print(side * side)   # I want to return this value instead

result = area_of_square(5)
print("Result:", result)

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post