How to write python codes in codechef

I tried the ATM problem of the tutorial section.
I wrote the following code.

a=int(input())
b=int(input())
if(a%5==0 and a<=b):
    print((b-a)-0.50)
else: print(b)

But an error occurred at line 1. Please guide me, how to write the input line!

1 Like

What error?

Are you trying to “Run” without Providing “Custom Input”?

1 Like

It’s working with custom input. But when I am submitting the code. Machine is providing the inputs in list format. That’s causing the error.

I even tried
# cook your dish here
a, b = list(map(int, input().strip().split(’ ')))
if(a%5==0 and a<=b):
print((b-a)-0.50)
else: print(b)
yet the NZEC error persists

Trying this solution with the sample test input:

30 120.00

gives the following error:

Traceback (most recent call last):
  File "./prog.py", line 2, in <module>
ValueError: invalid literal for int() with base 10: '120.00'

which is hopefully enough of a clue :slight_smile:

2 Likes

b==>int? are you sure

Do I need to change a, b = list(map(int, input().strip().split(’ '))) this line?

yes
chef is asking you to input 2 values

a and b are integer example(30,120)

but you have to input it as(30,120.00)

1 Like

problem was solved with a, b = list(map(float, input().strip().split(’ '))).

1 Like

To input two variables you don’t need to use list
you can use
a,b=map(float,input().split())
here, the split function will directly split it using spaces

I think it would not, In the question input is space separated.

yes my bad .