Home>

Thanks for your support.

I tried to make the following syntax to globalize some of the variables in a python function.

def misoshiru2 (x):
    print ("Miso soup \ n")
    print (str (x) + "Change the amount of salt to the age \ n")
    global enbun
    enbun = 1.2/x
    print ("salt" + str (enbun) + "g. \ n")
    print ("Melting soup and miso \ n")
    print ("Pour into the container and complete. \ n")
x = int (input ("Please tell me your age. \ n"))
misoshiru2 (x)
print (enbun)


Then
IndentationError: unindent does not match any outer indentation level
Will appear.

Yes,
enbun = 1.2/x
The Indent is strange, but if you indent it, it becomes Indent as mentioned above when you copy it, and an error occurs. What kind of device should I devise?
As an execution environment, we use a web application called Repl.it.

By the way, when starting up through python.exe, etc., Indent will probably be complete

  • Answer # 1

    More about it

    def misoshiru2 (x):
        print ("Miso soup \ n")
        print (str (x) + "Change the amount of salt to the age \ n")
        global enbun;enbun = 1.2/x
        print ("salt" + str (enbun) + "g. \ n")
        print ("Melting soup and miso \ n")
        print ("Pour into the container and complete. \ n")
    x = int (input ("Please tell me your age. \ n"))
    misoshiru2 (x)
    print (enbun)


    What if?

  • Answer # 2

    As far as I confirmed here, there seems to be no problem. Is it mixed with TAB characters? (If you post to StackOverflow, it will be converted to a space without permission.)

  • Answer # 3

    How about copying and running the code displayed on this page?
    It's running correctly here.