2017-02-12 4 views
-1

Hier ist mein Code:Mit Rückkehr von einer Funktion zur anderen Python

def options(): 
    wanted_float = float(input("Wanted Float: ")) 
    specificity = float(input("How close to float (ex: .001): ")) 
    low_output = float(input("Min Float of Output Skin: ")) 
    high_output = float(input("Max Float of Output Skin: ")) 
    needed_average = ((wanted_float-low_output)/(high_output-low_output)) 
    print("Needed average: ", needed_average) 
    only_lower = input("Only show floats lower than previous? yes/no: ") 
    which = input("Would you like to load floats manually or automatically? (manual/automatic): ") 
    return which 

def mode(which): 
    if (mode == 'manual'): 
     print("Manual") 

    if (mode == 'automatic'): 
     print("automatic") 

def start(): 
    options() 
    mode(which) 

start() 

Allerdings halte ich Fehler bekommen. Ich schaute mir einige andere Antworten an, die damit zu tun hatten, aber sie schienen sich nicht darauf zu beziehen.

Wanted Float: .5 
How close to float (ex: .001): .001 
Min Float of Output Skin: 0 
Max Float of Output Skin: 1 
Needed average: 0.5 
Only show floats lower than previous? yes/no: yes 
Would you like to load floats manually or automatically? (manual/automatic): manual 
Traceback (most recent call last): 
    File "C:\Users\.Anderson\Documents\Python\floats\organized.py", line 172, in <module> 
    start() 
    File "C:\Users\.Anderson\Documents\Python\floats\organized.py", line 161, in start 
    mode(which) 
NameError: name 'which' is not defined 

Der Grund sagt Linie 172 und 161 ist, weil ich eine Menge anderer Code haben zwischendurch, aber ich bin nur Optionen und Modus im Start Aufruf welcher der gesamte Code gegenwärtig der Fall ist

+1

Einfach '' mode (options()) '. Vielleicht möchten Sie über Variablen und Bereiche lesen –

+0

Welche Fehler? Veröffentlichen Sie bitte einen Stack-Trace. –

+1

Oder 'which = options()'. – jonrsharpe

Antwort

2

Problem ist, dass Sie die Rückgabe der options() -Funktion nicht gespeichert haben.

Sie können es wie mode (options()) oder which = options(); mode (which)

Verwandte Themen