2016-06-14 5 views
0

Ich bin mir nicht sicher, was ich in diesem Code falsch gemacht habe, aber aus irgendeinem Grund erzählt mir Eclipse immer wieder, dass die if-Anweisung einfach schlecht ist. Ich bin mir nicht sicher warum, wenn ich mir die Beispiele anschaue, sah es für mich gut aus.Ich benötige Unterstützung, um zu verstehen, was mit meinem Code falsch ist (if-Anweisungen)

penny = .01 
nickel = .05 
dime = .1 
quarter = .25 
print("Enter how many coins you want to use to make a dollar.") 
e_pen = int(input("Enter the amount of pennies you want: ")) 
e_nic = int(input("Enter the amount of nickels you want: ")) 
e_dim = int(input("Enter the amount of dimes you want: ")) 
e_qua = int(input("Enter the amount of quarters you want: ")) 

doll = float((e_pen * penny) + (e_nic * nickel) + (e_dim *dime) + (e_qua * quarter)) 
if doll > 1 # every conditional needs a : per the answer below 
    print("The total value is greater than 1 dollar.") # notice the indentation 
else   # same here 
    print("Try again.") 

Antwort

1

If-Anweisungen erfordern einen Doppelpunkt und die richtige Vertiefung finden Sie unter:

if doll > 1: 
    print("blah") 
else: 
    Print ("Try again") 

Hinweis, ist die Vertiefung 4 Räume.

Verwandte Themen