N
N
Neo-archer2020-05-01 05:14:59
Python
Neo-archer, 2020-05-01 05:14:59

Why does paycharm write in the text of the error that it is impossible to measure the length of a number, although the list is clearly visible, not the number?

5eab848ce3d89084429324.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Pankov, 2020-05-01
@Neo-archer

Because a number is not a string. It has no length.
If you need to count the number of decimal places in a number, then do this:
len(str(12345)) # 5

Y
yerdnaandrey, 2020-05-05
@yerdnaandrey

First you need to convert the number to a string, and only then measure the length.
Here is the code.

temp = str(temp)
print(len(temp))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question