2014-02-24 47 views
-1

我已經爲貨幣轉換器製作了這個代碼,但它提供了語法。請我使用python 3.3.2。我該如何修復這個貨幣轉換器的Python?

currencynum = 0 
yenpound=0.0059 
yendoler=0.0098 
yeneuro=0.0071 
yenyen=1 
yeneuro=0.0071 
yenyen=1 
poundyen=170.55 
pounddoler=1.67 
poundeuro=1.21 
poundpound=1 
dolpound=0.60 
doleuro=0.73 
doldol=1 
dolyen=102.37 
europound=0.83 
eurodol=1.38 
euroyen=140.79 
euroeuro=1 


tipe= input ("input what curontsy you have. yen y,us dollrus d, euro e, pound p.") 
      if tipe == "y": 
       print ("you have choson yen") 

      elif tipe == "e": 
       print("you have choson euro") 

      elif tipe == "d": 
       print ("you have choson us dollrus") 

      elif tipe == "p": 
       print ("you have choson pound") 

      howmuch = float(input("how much do you have")) 

      otheramount = input ("input what curontsy you want to convert. yen y,us dollrus, euro e, pound p.") 

      if otheramount == "y": 
       print ("you have choson yen") 
      elif otheramount == "e": 
       print("you have choson euro") 

      elif otheramount == "us": 
       print ("you have chosen us dollrus") 

      elif otheramount == "p": 
       print ("you have choson pound") 


      if tipe == "y": 


        if otheramount == "y": 
         print ("yy") 
        currencynum=howmuch*yenyen 
        print (currencynum) 

        elif otheramount == "e": 
         print ("ye") 
        currencynum=howmuch*yeneuro 
        print (currencynum) 

        elif otheramount == "d": 
         print ("yd") 
        currencynum=howmuch*pounddoler 
        print (currencynum) 


        elif otheramount == "p": 
         print ("yp") 
        currencynum=howmuch*yenpound 
        print (currencynum) 


      elif tipe == "e": 

        if otheramount == "y": 
         print ("ey") 
        currencynum=howmuch*euroyen 
        print (currencynum) 

        elif otheramount == "e": 
         print ("ee") 
        currencynum=howmuch*euroeuro 
        print (currencynum) 

        elif otheramount == "d": 
         print ("ed") 
        currencynum=howmuch*eurodol 
        print (currencynum) 

        elif otheramount == "p": 
         print ("ep") 
        currencynum=howmuch*europound 
        print (currencynum) 

      elif tipe == "d": 

        if otheramount == "y": 
         print ("dy") 
        currencynum=howmuch*dolyen 
        print (currencynum) 

        elif otheramount == "d": 
         print ("dd") 
        currencynum=howmuch*doldol 
        print (currencynum) 

        elif otheramount == "p": 
         print ("dp") 
        currencynum=howmuch*dolpound 
        print (currencynum) 

        elif otheramount == "e": 
         print ("de") 
        currencynum=howmuch*doleuro 
        print (currencynum) 

      elif tipe == "p": 

        if otheramount == "y": 
         print ("py") 
        currencynum=howmuch*poundyen 
        print (currencynum) 

        elif otheramount == "p": 
         print ("pp") 
        currencynum=howmuch*poundpound 
        print (currencynum) 

        elif otheramount == "d": 
         print ("pd") 
        currencynum=howmuch*pounddoler 
        print (currencynum) 

        elif otheramount == "e": 
         print ("pe") 
        currencynum=howmuch*poundeuro 
        print (currencynum) 


      #currency = tipe + otheramount 

      #command=currency 
      #total= howmuch * currencynum 
      #print (total) 
+0

歡迎來到StackOverflow!在這裏你有一個你好。使用配對數據名稱值時,最好將其存儲爲字典。它說的是什麼類型的錯誤,通常它說的是類似於第42行錯誤: SyntaxError:....'。你有沒有試圖糾正這條線? – Llopis

回答

0

你的問題似乎是從壞的壓痕.. 你需要大約4個空格(不知道這是版本有關,有時需要6〜8)每個壓痕,然後它會工作。 請記住,每個新的if語句都需要另一個縮進,並且您的乘法應該放在if塊中,因此它也必須縮進!