-8

I wanted to post a question on Stack Overflow.

I tried posting a code with its error. But, it showed some indentation error in code.

I was not able to find any {} above to resolve the problem. Although the error indicated to asked 4 whitespaces before the code, it did not work. Many answers which already answered this question asked to try Ctrl + K. But, again the same error persisted.

How did I post the question at the end?

I removed the error, added a screenshot image of the code+error and made the already written code in Rich text mode and and added Code block. And the error vanished! I do not know the exact reason, but with so many trial and error, I was finally able to post my question. It would be of great help if anyone can help me with the correct way of posting a question which has a code and it's error and not just uploading the image.

8

1 Answer 1

1

This is how the post looked when I opened it to edit and fix problems:

enter image description here

And here it is after:

enter image description here

I used an image editor to circle the {} button so that you can see exactly where it is.

To use this button, first select the text that should be the code, and then press the button. Or you can select the text, and then press Ctrl+K.

I fixed the post by removing the > symbols, which come from using the quote feature (the " button, to the left of the {}) in the same way. I also fixed some other small problems with how the question is written, in order to show what good Stack Overflow questions should look like. (But a good question also needs to be properly researched, and the problem needs to be clearly defined and reproducible.)

It does not matter what buttons you click, or what you press on the keyboard, or what you see in rich text mode. Stack Overflow only cares about the text that is shown in the Markdown editor when you submit the post.

For future questions, please do not show us an image. We will not transcribe the image for you (copy out the text and format it for you).

It's also helpful to read error messages carefully and try to reason about the problem. It did not help when you changed the variable name lines to a different name, because that was not the problem. The error message says there is a problem because something "is not callable". That means, you tried to call something, and it is not possible to call that thing. When you write str(lines), the thing that you call is str, and lines is what you call it with. Therefore, we know that the problem must be with str, not with lines.

Normally, str should be callable; the meaning is built in to Python. But it's possible to replace this (in other code that you did not show in the post). Your question is very commonly asked by beginners, so we closed it as a duplicate. We have an existing question that explains very carefully how this problem happens, why it is possible, and what to do about it.

Disclosure: I did a lot of work to try to improve the question and answers there. There are some other old questions that are about as popular and almost exactly the same. We did not come to a clear agreement about which one to use to answer beginners.

9
  • 3
    Apologies to the Meta community for not drawing the circles freehand. At least I did not actually constrain their dimensions, so they are almost certainly ellipses instead. Commented Nov 24, 2023 at 5:38
  • 3
    In an act of solidarity & compassion (if you love something, set it free) I have edited your images.
    – philipxy
    Commented Nov 24, 2023 at 5:45
  • 2
    I think OP here got confused by the new editor (Ask wizard uses it by default). The button to add a code block looks different in it Commented Nov 24, 2023 at 5:51
  • 1
    @AbdulAzizBarkat Yeah seems likely. Any easy way to see that editor mode/view now that meta.SO/meta.SE are back to the old editor for me?
    – philipxy
    Commented Nov 24, 2023 at 5:58
  • 1
    @philipxy you can configure your preferences on Meta to use the beta of the new editor. Commented Nov 24, 2023 at 6:02
  • 3
    @AbdulAzizBarkat Thanks. Unfortunately I would rather configure them to make my head explode. Oh wait those are the same thing. One is just more slow & painful.
    – philipxy
    Commented Nov 24, 2023 at 6:04
  • 1
    @AbdulAzizBarkat Ha ha ha I just changed that mode then clicked on edit to open in a new tab and saw the old editor then clicked reload then saw the new editor. OMG Hopeless.
    – philipxy
    Commented Nov 24, 2023 at 6:10
  • @AbdulAzizBarkat Yeah the edit window header for the new editor has no {} icon.
    – philipxy
    Commented Nov 24, 2023 at 6:12
  • @philipxy edited ... and switched. It now looked like Karl added ">" to each line :P.
    – Tom
    Commented Nov 24, 2023 at 16:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .