I was typing a sample code. Where I defined temperature as the main function, but I was unable to run it. It closed automatically without any input prompt.
def temperature():
number = input('Enter what you want\n')
values = number.split(' ')
temperature = values[0]
unitin = values[1]
unitout = values[-1]
print(temperature, 'this', unitin, 'is', unitout, 'working') # this is working is a test statemment i was unsure
print('This is a test function', number)
def main():
temperature()
if __name__ == "__main__":
main()
this is the part of the code that ran. But as soon as I tried to change just the name of the main function it stopped working. I am not sure, does it only take the name "main"?
def readinput():
input_string = input('Enter what you want\n')
values = input_string.split(' ')
temperature = values[0]
unitin = values[1]
unitout = values[-1]
print(temperature, 'this', unitin, 'is', unitout, 'working')
print('This is a test function', input_string)
def temperature_converter():
readinput()
if __name__ == "__temperature_converter__":
temperature_converter()
This is the code that did not work. thank you.