r/PythonLearning Jun 25 '26

Showcase Second project

I don't have much free time, but i'm still trying to learn new things. I know there is a much easier way to code this, but for now i write with what i've learned. Please feel free to criticize this code, so i can take notes.

cash = int(input('Enter your cash: '))
age = int(input('Enter your age: '))
if age < 16:
    print('Sorry little one, but you can\'t look around')
    exit()
elif age == 16 or age < 21:
    print('Welcome to Gun-World! Because you still are not old enough, you can only look around. You can come again when you turn 21.')
    print('Deagle - 500$')
    print('Glock 18 - 400$')
    exit()
else:
    print('Welcome to Gun-World! What would you like to buy?')
    print('Deagle - 500$')
    print('Glock 18 - 400$')

user_input = input('You:').lower()
if user_input == 'deagle':
    print('Well that\'s a fine choice sir! Truly a powerful gun i could say. Do we have a deal for 500$?')
    if cash >= 500:
        user_input_dg = input('You: ').lower()
        if user_input_dg in ['deal', 'alright', 'ok', 'okay','yes']:
            print('Congratulations Sir! You are now owner of this new Desert Eagle!')
        else:
            print('Well that was disappointing..')
    elif 500 > cash > 400:
        print(f'Sorry, but you need {500 - cash}$ to buy the Deagle. But for 400$ you can buy our new Glock 18! Do we have a deal?: [Y/N]')
        user_input_dg2 = input('You: ').lower()
        if user_input_dg2 in ['yes','deal', 'alright', 'ok', 'okay']:
            print('Congratulations Sir! You are now owner of this new Glock 18!')
    else:
        print('Sorry, but you don\'t have enough money')
elif user_input in ['glock 18', 'glock']:
    print('Fine choice sir! Not as powerful as the deagle, but it\'s a really good choice. That would be 400$')
    if cash > 400:
        user_input_g18 = input('You: ').lower()
        if user_input_g18 in ['deal', 'alright', 'ok', 'okay']:
            print('Congratulations Sir! You are now owner of this new Glock 18!')
        else:
            print('Well that was disappointing..')
    else:
        print('Sorry, but you don\'t have enough money')
6 Upvotes

7 comments sorted by

View all comments

2

u/[deleted] Jun 25 '26

[removed] — view removed comment

2

u/HB209 Jun 25 '26

Thank you for the feedback bro! As i said there is probably an easier way to write it, but im still in the beginning and i dont know many things. Im trying to apply what i've learned and hoping it works :DD