如何解决这个python程序中的错误?

时间:2015-01-12 17:42:21

标签: python function output indentation

我是python的初学者,我有很多很多关于它的问题。我试图创建一个程序,但我没有得到完全的结果。只有很少的计算,休息是印刷品。

它是这样的:

 def travelmanagement():
  trate=[]
  totrate=[]
  finrate=[]
  frate=[]
  print"WELCOME TO..........MESSAGE"
  print"ARE YOU A VISITOR OR MEMBER"
  ch1=raw_input("Enter your choice")
  V="VISITOR"
  v="visitor"
  if(ch1==V)|(ch1==v):
           print"To proceed further,you need to a create account/use guest session"
           print"A.Create Account"
           print"B.Guest Session"
           ch2=raw_input("Enter your choice")
           if(ch2=="A")|(ch2=="a"):
                     Name=raw_input("Enter your name:")
                     Username=raw_input("ENter your username")
                     Password=raw_input("ENter your password")
                     Confirm=raw_input("Confirm your password")
                     DOB=raw_input("DD: MM: YY: ")
                     Gender=raw_input("I am....")
                     Mobile=input("Enter your mobile number")
                     Location=raw_input("Enter your current location")
                     print"Prove you are not a robot,Type the text shown below"
                     print"trufle"
                     text="trufle"
                     type=raw_input("Type your text")
                     if(Password==Confirm)&(type==text):#proceed works only after if  is satisfied
                                       def proceed():
                                             print"You have created account"
                                             print"You can now proceed!!"
                                             print"Welcome",Username
                                             print"TMS specializes in touristplaces"
                                             print"P1.DELHI"
                                             print"P2.GOA"
                                             ch3=raw_input("What's your destination?")
                                             pl=['delhi','goa']
                                             t=['t','c','b','p']
                                             gp=[200,400]#general #rate for choosing place
                                             gt=[200,300,400,500]#general rate for choosing transportation
                                             print"""TMS specializez
                                             t.Railways
                                             c.Car
                                             b.Bus
                                             p.Plane"""
                                             ch4=raw_input("ENter your choice")
                                             if(ch4=="t"):#displays timmings of transportation
                                                     print"HYPERSONIC HAIRTRIGGER"
                                                     print "Timmings:"
                                                     print "DELHI"
                                                     print ".............."
                                                     print "GOA"
                                                     print ".............."
                                                     print "VELOCIOUS PALACE"
                                                     print "Timming"
                                             if(ch4=="c"):
                                                      print"CArs available:"
                                                      print"BMW"
                                                      print"SWIFT"
                                                      print"......."
                                                      print"........"
                                             if(ch4=="b"):
                                                      print"Buses available"
                                                      print"................"
                                                      print"""delhi
                                                      timiings
                                                      .........
                                                      goa

                                                      .................."""

                                             if(ch4=="p"):
                                                      print"""Planes available
                                                      ........just like abv"""
                                             for i in range(0,2,1):
                                                        for j in range(0,4,1):
                                                            if(pl[i]==ch3)&(t[j]==ch4):
                                                                     trate=gp[i]*gt[j]

                                             return ch3,ch4      

                                       def accomodation():

                                                    print"""specialises
                                                    1.place 1
                                                    a.hotel 1
                                                    b.hotel 2
                                                    Hotel1:ac/non ac rooms
                                                    Ac.for ac...
                                                    Noac.for non ac....
                                                    b.Hotel2
                                                    Ac.ac..
                                                    Noac.non ac...
                                                    2.place 2
                                                    a.Hotel1:ac/non ac rooms
                                                    A.for ac...
                                                    N.for non ac...
                                                    b.Hotel2
                                                    A.ac..
                                                    N.non ac..."""
                                                    genh1=[5000]#general rate for choosing hotel1
                                                    genh2=[4000]#general rate for choosing hotel2
                                                    ch5=input("Enter ypur choice")
                                                    fav=raw_input("ENter hotel choice")
                                                    mode=raw_input("Enter ac/no ac")
                                                    TAc=[1000]#rate for ac room
                                                    Nac=[400]#rate for non ac room
                                                    if(ch5==1):
                                                         if(fav=="a"):
                                                             if(mode=="Ac"):
                                                                 frate=genh1+TAc
                                                             else:
                                                                  frate=genh1+Nac
                                                         elif(fav=="b"):
                                                               if(mode=="Ac"):
                                                                   frate=genh2+TAc
                                                               else:
                                                                    frate=genh2+Nac
                                                    elif(ch5==2):
                                                           if(fav=="a"):
                                                               if(mode=="Ac"):
                                                                    frate=genh1+TAc
                                                               else:
                                                                   frate=genh1+Nac
                                                           if(fav=="b"):
                                                                if(mode=="Ac"):
                                                                    frate=genh2+TAc
                                                                else:
                                                                    frate=genh2+Nac
                                                    else:
                                                           totrate=totrate+frate+trate
                                                    print"Due to prefer a guide??"
                                                    print"a guide inperson...rate=1000"
                                                    print"maps,3g....rate=2000"
                                                    ch6=raw_input("ENter your choice")
                                                    if(ch6=="person")|(ch6=="PERSON"):
                                                        totrate=totrate+[1000]
                                                    elif(ch6=="gadget"|ch6=="GADGET"):
                                                        totrate=totrate+[2000]
                                                    else:
                                                        return totrate


                                       x=proceed()
                                       y=accomodation()
                                       print x
                                       print y
                      else:
                             print"invalid"


                #if(ch1==b) is present after this.Same lines as above is repeated 
 travelmanagement()

缩进是正确的。错误是“totrate在赋值之前被引用”我在允许全局变量的所有地方都给它但仍然没有来。当我得到结果时,finrate的数量没有得到打印。或者0来了。请让我知道错误。我有什么我应该导入的 - 抱歉的麻烦。它是一个课堂演示。 谢谢你的努力。

0 个答案:

没有答案