r/pythonhelp • • Jul 02 '22

Python assistance needed PLEASE!

So, I have been getting into python recently as my first real dive into coding(/programming idrk feel free to correct), and I have this bit of code..

----------

print('How many bois you got in your pocket?')
dolla = input()
A = 0.01
w = 0
T = 0.05
x = 0
F = 0.10
y = 0
G = 0.25
z = 0
if[dolla > G]:
z + 1
else:
if[dolla > F]:
y + 1
else:
if[dolla > T]:
x + 1
else:
w + 1
print('Your dolla = ' + w + " Andrew, " + x + ' Thomas, ' +
y + ' Franklin, and ' + z + ' Georgies.')
if{dolla >= 1}:
print(' Congrats on having a masive cock!')
else:
    (" I'm so sorry for your accident involving your weener!")
----------

It shows no errors just sitting in Visual Studio Code, but shows this error when I enter "20"(no quotes) into the input box:

TypeError: '>' not supported between instances of 'str' and 'float'

I have tried a few things so far, but have not had any luck in fixing this error..

PLZ HLP,

-RR

5 Upvotes

3 comments sorted by

View all comments

1

u/FM_Studios Jul 02 '22

try adding this after the input function:

try:

dolla = float(dolla)

except:

print("Can't convert into number!")

continue #ONLY USE THIS LINE IF THE CODE IS IN A WHILE / FOR LOOP (optional but recomended)