-1

I am a beginner in python programming & learning the basics from online. The below code works as shown in online video tutorial but gives blank output while I run in my machine. I am using python 2.7.14 version. Writing the code in Sublime editor and using the cmd to run the file. I have some other code which runs perfectly fine.

I want to know what is wrong with the below code as it is not printing the desired line /blank.

def main():
    x, y = 10, 100  

    if (x < y):
        st = "x is less than y"
    elif (x == y):      
        st = "x and y are same"
    else:
        st = "x is greater than y"

    print (st)
martineau
  • 119,623
  • 25
  • 170
  • 301
Nusrat
  • 85
  • 3
  • 13
  • 1
    You need to call the function. At the end of the file, put `main()` without any indentation. – zondo May 20 '18 at 17:36

1 Answers1

1

You have to call the function main():

def main():
    x, y = 10, 100

    if (x < y):
        st = "x is less than y"
    elif (x == y):
        st = "x and y are same"
    else:
        st = "x is greater than y"

    print(st)

main()

Output:

x is less than y
  • @Nusrat: You have defined the function but never called it so that's why you didn't get the output diplayed. Now you can test it –  May 20 '18 at 17:38