View Single Post
Old Aug 14th, 2005, 4:01 PM   #1
verb1426
Newbie
 
Join Date: Aug 2005
Posts: 26
Rep Power: 0 verb1426 is on a distinguished road
Are there any alternatives for GOTO in Python?I am facing a problem please respond.

بسم الله الرحمن الرحيم
Hi guys

I have designed a program that converts the date from Islamic calendar to Christian calendar.Unfortunately, I have faced a REAL problem (I mean a REAL problem for me as a beginner). First Here is the program:


print " Welcome to date converting program"
print " ------------------------------------"
print
print " Please choose the number for the converting process you wish to perform:"
print
print "1- From Christian calendar to Islamic calendar."
print "2- From Islamic calendar to Christian calendar."
print
a = input ("The number:")
if a == 1:
d = input ("Enter the date:")
g = d - 579
if g <0:
print "The date in the Islamic calendar is" , g - g - g , "BH"
else:
print "The date in the Islamic calendar is" , g , "AH"
elif a == 2:
d = input ("Enter the date:")
print "The date in the Christian calendar is" , d + 579 , "AD"
else:
print "Restart the program and enter the right number."


-------------------------
But as you can see, since there is no GOTO function in Python, I had to write :"Restart the program and enter the right number."

I would appreciate it if anyone could modefy this program or show me how to modefy it so that if I choose a number that is not on the list it returns to the line which says: a = input ("The number:")

Thank you.
verb1426 is offline   Reply With Quote