Python Forum
Help in writing a basic function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help in writing a basic function
#1
:I'm learning to write python code with a book, In the chapter about functions there is the following function example
def seven_eleven():
    x = 8
    y = 30
    return x, y


def main():
    var1, var2 = seven_eleven()
    print var1, var2
I tried to write the code but the output was "Process finished with exit code 0" instead of 8 and 30
?what did i do wrong
Reply
#2
You need to call function main() to execute it. Add
main()
at the end of the program.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Function parameter not writing to variable Karp 5 984 Aug-07-2023, 05:58 PM
Last Post: Karp
  Create a function for writing to SQL data to csv mg24 4 1,206 Oct-01-2022, 04:30 AM
Last Post: mg24
  Writing into 2 text files from the same function paul18fr 4 1,709 Jul-28-2022, 04:34 AM
Last Post: ndc85430
  I am writing a car rental program on python. In this function I am trying to modify aboo 2 2,783 Aug-05-2021, 06:00 PM
Last Post: deanhystad
  Writing a lambda function that sorts dictionary GJG 1 2,039 Mar-09-2021, 06:44 PM
Last Post: buran
  Writing a basic shift code djwilson0495 2 2,291 Aug-16-2020, 01:52 PM
Last Post: djwilson0495
  basic random number generator in replace function krug123 2 2,067 Jul-31-2020, 01:02 PM
Last Post: deanhystad
  Writing a function to calculate time range in Unix Epoch Time t4keheart 2 3,039 Jul-15-2020, 01:55 AM
Last Post: t4keheart
  Basic function python sernikov 9 167,107 Jan-14-2020, 08:58 AM
Last Post: perfringo
  Writing a function that accepts a path to an input file says 3 3,311 Aug-29-2018, 05:20 AM
Last Post: buran

Forum Jump:

User Panel Messages

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