Nov-09-2022, 02:42 AM
(This post was last modified: Nov-09-2022, 06:22 AM by Yoriz.
Edit Reason: Added code tags
)
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-
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()

![[Image: wWvxiv.png]](https://imagizer.imageshack.com/v2/xq90/922/wWvxiv.png)