-2

Can someone tell me what's wrong with this program?

-------- cut here -----------

import sys

def temp_converter_2(degree):
  print("Do you want to convert to Celsius or Fahrenheit? Enter C or F")
  answer = str(sys.stdin.readline())

  if answer == "C":
    converted_value = (degree - 32) * 5/9
  elif answer == "F":
    converted_value = (degree * 9/5) + 32
  else:
    print("That's not C or F")
    converted_value = -99;

  print(converted_value)

def __main__():
  print("Enter temp to convert:")
  temp = int(sys.stdin.readline())
  temp_converter_2(temp)

------- cut here --------

When I run it, I get nothing. I am hoping that it will ask me for input. What am I missing?

MacBook-Pro-(9):stuff$ python temp_converter_2.py MacBook-Pro-(9):stuff$

Vhas21
  • 1

1 Answers1

0

You need to call your __main__ function for the program to get executed. So below everything put:

__main__()

Your function probably shouldn't be named __main__ though since the double underscore functions/variables have special meanings, better name would be main.

ruohola
  • 21,987
  • 6
  • 62
  • 97