Python Forum
Need help with a function that calls other functions.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with a function that calls other functions.
#5
As Ichabod stated, the functions need to have values for their arguments; there's no way around it. However, there are a couple addition items to change to accomplish your goal.

Line 48 won't work. A for loop only works on objects with a __next__() method. This line will raise a NoneType error, most likely. For your desired outcome, you don't need a for loop at all; the variables "a" and "b" are already there.

Lines 49 - 51 will print a memory location instead of the output of the functions. This is due to the functions being referenced but not called. To call them, parentheses are needed afterward along with their argument values.

Line 52 will print "None" because skrivBeregninger() does not return a value. You may want to return all three functions in a tuple from skrivBeregninger().

def skrivBeregninger():
    a=input ("Skriv inn tall 1: ")
    b=input ("Skriv inn tall 2: ")
    return (addisjon(a, b), subtraksjon(a, b), divisjon(a, b))
Reply


Messages In This Thread
RE: Need help with a function that calls other functions. - by stullis - Sep-30-2019, 09:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  asyncio calls within sync function ( Websocket on_open) orion67 0 1,402 Jan-16-2022, 11:00 AM
Last Post: orion67
  Calls to Attributes of a Class SKarimi 3 3,379 Apr-22-2021, 04:18 PM
Last Post: SKarimi
  Combine Two Recursive Functions To Create One Recursive Selection Sort Function Jeremy7 12 7,356 Jan-17-2021, 03:02 AM
Last Post: Jeremy7
  list call problem in generator function using iteration and recursive calls postta 1 1,895 Oct-24-2020, 09:33 PM
Last Post: bowlofred
  RuntimeError: Optimal parameters not found: Number of calls to function has reached m bntayfur 0 6,140 Aug-05-2020, 04:41 PM
Last Post: bntayfur
  Run a timer when a functions starts to see how long the function takes to complete Pedroski55 2 1,995 Apr-19-2020, 06:28 AM
Last Post: Pedroski55
  How to split a string containing function calls? Metalman488 4 2,874 Oct-27-2018, 06:50 PM
Last Post: Metalman488
  call a function from other functions ... evilcode1 2 2,739 Sep-05-2018, 09:07 AM
Last Post: evilcode1
  Testing function calls jenselme 1 2,675 Jul-25-2018, 10:33 AM
Last Post: Larz60+
  argument parser: to execute single function, and subsequent functions also raghu 10 5,858 Mar-12-2018, 06:57 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020