Python Forum
How to run code again in module ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to run code again in module ?
#1
Hi all,
I'm a new to python and coding.

How to run back the code when a user chooses an option ?

- the code i have currently-
print('Now you try')
print('This is how to get the volumetric weight for cargo space calculation')


num1 = input('Enter length number: ')
num2 = input('Enter width number: ')
num3 = input('Enter height number: ')
sum = float(num1) * float(num2) * float(num3) / 5000

print('This is for your shipment information')

char1 = input ('Please enter your name: ')
char2 = input ('Please enter comp name: ')
char3 = input ('Please enter reference: ')

char4 = input ('Please enter you consignee name: ')
char5 = input ('Please enter consignee comp name: ')
char6 = input ('Please enter shipment value: ')

print ('Conclusion')

print('The sum of {0} and {1} and {2} divided by 5000 is = {3} cm3'.format(num1, num2, num3, sum))
print('Your name is {0}'.format(char1, ))
print('Your company is {0}'.format(char2, ))
print('Your reference is {0}'.format(char3, ))
print('Your consignee name is {0}'.format(char4, ))
print('Your consignee company name is {0}'.format(char5, ))
print('Your shipment value is ${0}'.format(char6, ))


print('What do you want to do next ?')

choice = input("""
                      A: Continue
                      B: Logout

                      Please enter your choice: """)

if choice == "A" or choice =="a":restart("test1.py",) stuck here, I don't know which command to use to loop back the code on top
elif choice == "B" or choice =="b":quit() - this works.
else:
        print("You must only select either A or B")
        print("Please try again")
        menu()
Yoriz write Nov-09-2022, 06:22 AM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
How to run code again in module ? - by rajamani - Nov-09-2022, 02:42 AM
RE: How to run code again in module ? - by snippsat - Nov-10-2022, 02:38 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020