Python Forum
Print out the tuple from the function main
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print out the tuple from the function main
#1
Here i created a function main where i have a list of tuple which store 'Science', 'Math', 'Computer' but when i call the function in line 5 it doesn't print out the tuple but the compilation went without any error.

#!usr/bin/python

def main():
    tup = ('Science',  'Math',  'Computer')
    print(sorted(tup))

if __name__=='main':
    main()
why does the print function doesn't print out the tuple?
Reply
#2
Try __name__ == "__main__" instead (dunder main).
Reply
#3
Thanks it worked i must be too blind to see that :(
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  print doesnt work in a function ony 2 233 Mar-11-2024, 12:42 PM
Last Post: Pedroski55
  How to print variables in function? samuelbachorik 3 851 Dec-31-2022, 11:12 PM
Last Post: stevendaprano
  How to print the output of a defined function bshoushtarian 4 1,235 Sep-08-2022, 01:44 PM
Last Post: deanhystad
  Function global not readable by 'main' fmr300 1 1,295 Jan-16-2022, 01:18 AM
Last Post: deanhystad
  Why does absence of print command outputs quotes in function? Mark17 2 1,341 Jan-04-2022, 07:08 PM
Last Post: ndc85430
  return vs. print in nested function example Mark17 4 1,674 Jan-04-2022, 06:02 PM
Last Post: jefsummers
  output correction using print() function afefDXCTN 3 10,960 Sep-18-2021, 06:57 PM
Last Post: Sky_Mx
  Tuple generator, and function/class syntax quazirfan 3 3,758 Aug-10-2021, 09:32 AM
Last Post: buran
  Sort Function: <' not supported between instances of 'float' and 'tuple' quest 2 7,971 Apr-30-2021, 07:37 PM
Last Post: quest
  print function output wrong with strings. mposwal 5 3,044 Feb-12-2021, 09:04 AM
Last Post: DPaul

Forum Jump:

User Panel Messages

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