I don't know what to do with Python, so I was studying the def syntax, and I asked because I had a question.
The contents below are what I did.
Questions
Is there a way to use the def phrase as a plural number and use it twice for the glass and drink?
When I input(), it says "I'm" or "Cup" separately, so it overlaps, so you ordered 2 cups of cider. Is there a way to make an exception and ask again or change it so that an error mark appears?
python def
If you're a beginner, try it and ask questions. That's how you improve your skills.
def order_beverage():
drink = input ('Tell me what you want to order')
while True:
confirm = input(f'{drink} correct? (Y/N) Cancel:Q')
if confirm in ['Y', 'y']:
return drink
elif confirm in ['Q', 'q']:
return ''
def order_cnt():
while True:
order_cnt = input('How many cups would you like to order?')
try:
order_cnt_number = int(order_cnt)
except ValueError:
Please enter only print(f)' numbers.[Not a number: {order_cnt}]')
else:
return order_cnt_number
ordering_flag = True
while ordering_flag:
drink = order_beverage()
if drink:
ordering_flag = not ordering_flag
cnt = order_cnt()
A glass of print(f'{drink} {cnt} has been ordered.')
915 Uncaught (inpromise) Error on Electron: An object could not be cloned
845 M2 Mac fails to install rbenv install 3.1.3 due to errors
796 GDB gets version error when attempting to debug with the Presense SDK (IDE)
1338 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2025 OneMinuteCode. All rights reserved.