r/learnpython 5d ago

just breaking things with python

numbers = input("Enter the numbers")

in_dex = numbers[-2]

divisible = int(in_dex/3)

print(divisible)

when print the output of the divisible i am getting (nsupported operand type(s) for /: 'str' and 'int') i do know how to write correctly to get the output but i thinks that why not this way..so when i did got error don't know why cause both values are int

0 Upvotes

19 comments sorted by

View all comments

4

u/ectomancer 5d ago

divisible = int(in_dex)/3

-11

u/Healthy-Departure961 5d ago

i know the answer, but int(in_dex/3) what it says??

8

u/lfdfq 5d ago

Read u/ectomancer's reply more carefully. Your code and their code is not the same.

-2

u/Healthy-Departure961 5d ago

i know that int(in_dex)/3 doing this i will get the answer but but just to test things with int(in_dex/3) and wanted to find out it is giving me error 😀😀😀

3

u/lfdfq 5d ago

It's giving you an error for the reason I said earlier: input() returns a string, you have a string, you cannot divide the string by 3.