Len function retur always 0


somebody help me please

For future questions, please read the pinned thread and show the code and errors as properly formatted text - by copying and pasting the text and formatting it in separate blocks. Python error messages should use the same formatting as code. (It’s also a good idea to try to ask an actual question, instead of saying “somebody help me please” and making people guess what it is that you don’t understand.)

input(32) means “show the number 32, converted to a string, as a prompt; then use the value that was entered”. It does not mean that 32 will be any kind of “default” value for the input. In your case, you pressed the Enter key immediately when you saw the 32, so the input is an empty string.

If you want to input the string 32, you have to type it yourself before you press Enter, in response to the prompt. (Don’t use quotes; you’re typing actual text here, not Python code.)

If you don’t want input from the user, but just want to set two_digit_number to be the string '32', you can specify that directly; or if you want to convert from the integer 32, use str, like: two_digit_number = str(32). (There is not really any point to this as written; normally, you would do it with some other variable, that got its value from a previous calculation.)

im sorry for this, but my english is very bad and so it s very difficult to explain for me. for this reason i decide to post a screenshot. thank for the answer

Hello,

use google translate: https://translate.google.com/

Enter your question in your native language on the left pane then copy and paste the translated version from the right side (just make sure the correct languages are selected although it generally is able to guess the entered language).

1 Like

Sometimes it’s better to have a good native-language post than a bad translated-language post because a bad translation can obscure the meaning, especially when the translation software picks a wrong word for the translation.

For example, I used the word “post” in the previous sentence, but I didn’t mean a “wooden post”!

If you (the reader) can see the word “post”, then you can see that it has multiple meanings and can determine the correct one given the context.

1 Like

As far as I know, it’s okay if you want to post in your native language here - it happens now and then.

But we still want code and errors as properly formatted text, not as a screenshot. That way, we can copy and paste the text ourselves - to test it and for discussion.

1 Like

I think that’s true, but (a bit like posting screenshots) it will get fewer responses than in the majority language.

@sergio6 : The argument to the input function is the prompt, that is the instruction you want to give the user. It is usually a string (text), like this:

>>> two_digit_number = input("Give me a number:")
Give me a number:

Then it waits.

In your case, Python has printed your prompt “32”, but it looks like you entered nothing, that is, you entered an empty string. If you had entered a two digit number, it would have gone like this:

>>> two_digit_number = input("Give me a number:")
Give me a number:42
>>> two_digit_number
'42'

Postscript: If you follow the advice in the pinned thread, your code will come out like the above. That means you can copy and paste it. (Don’t copy the prompts.)

1 Like

You are not using the input() function correctly. Input requires can use a string as a parameter which is displayed to the user and is tells the user what to enter, and the value the user enters will be assigned to a variable.

myvar = input("Enter a number:")
print(myvar)

Also be careful with case. Python is a case-sensitive language.

Are you taking your first programming class? That’s fine I’m just curious.

Yes, I’m having my first lessons