i m новичок в python, и у меня есть много и много вопросов об этом. Я попытался создать программу, и я не получаю результат точно. Только небольшой расчет есть, остальное - печатная статья.Как решить ошибку в этой программе 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 упоминается перед тем назначением» proper.The ошибки я дал его во всех местах, где глобальные переменные разрешены, но до сих пор оно не come.And, когда я получите результат, размер финиша не будет напечатан. Вместо этого ничего или 0 не приходит. Сообщите мне об ошибках. Там что-то я должен импортировать? Извините за неприятность. Он предназначен для презентации класса. Спасибо за ваши усилия.
Это углубление. – Christian
Исправьте свой отступ, конечно, ваш код не будет работать, если он выглядит так. –
Ваш отступ ** не ** «правильный». Возможно, пространство перед первой и последней строками является простой ошибкой при вставке кода в ваш вопрос, но последний 'else:' (до 'print 'invalid" ') не соответствует никакому' if' в вашем коде , Отступ должен всегда ** быть четырьмя пробелами на уровне; в противном случае вы пропустите ошибки, подобные этому, и ваш код будет болезненным для чтения другими пользователями (что означает, что они не захотят его отлаживать). –