Wrong solution for https://www.codechef.com/submit/HS08TEST

can someone please tell me what’s wrong with my code?
it’s written in python 3.6.

inp_str = input().split(’ ')

wtd_amnt = float(inp_str[0])
bal_amnt = float(inp_str[1])

lst_dgt = float(inp_str[0][len(inp_str[0]) - 1])

if lst_dgt in (5, 0) and wtd_amnt != 0:
if wtd_amnt + 0.5 < bal_amnt :
print(’%.2f’ %(bal_amnt - wtd_amnt - 0.5))
else: print(’%.2f’ %(bal_amnt))
else: print(’%.2f’ %(bal_amnt))

The single quotes you have used are not of the correct form, so syntax error issue is arising.
your single quote → ’’ single quote accepted on codechef → ''

The quote problem is probably caused by CodeChef while publishing, I solved the problem within 5 min after publishing, the problem was that I forgot to consider the balance amount = withdrawal amount + 0.5 case where it gave me a wrong result.

So all I had to do was change:
if wtd_amnt + 0.5 < bal_amnt :
to
if wtd_amnt + 0.5 <= bal_amnt :

Great to know and sorry for the misunderstanding from my side.

From next time please type the code as preformatted text, you just need to click on the preformatted text option(highlighted button in screenshot) and then type the code inside the triple quotes that comes, this way the code isn’t affected.

1 Like