Wieso tut mir Python das an :-(?

Ich möchte eine eigene Library in Python erstellen, die mathematische Befehle hinzufügt (ich weiß so etwas gibt es schon).

Das ist mein Programm:

def MathRoot(x):

   x= int(x)

   y= x**0.5

   x=y

z=int(MathRoot(25))

print(z)

Was ich als Ausgabe jedoch erhalte ist “None” und nicht das gewünschte Ergebniss. Kann mir bitte jemand erklären was ich möglicherweise falsch gemacht habe. Ich danke schonmal im Voraus.

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
2 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
KuarThePirat
2 months ago

You have to return something from the function. So instead of x=y

def MathRoot(x):
   x = int(x)
   y = x**0.5
   return y