1

I have a question about my Stack Overflow post: How can I check if a string contains only English characters, exclamation marks at the end?

Based on my thoughts and the question below I want honest feedback from meta about how I should improve and what changes in my thinking I should bring so that I can be a better user on this website. I am open to change my thoughts. I want to see myself as a person who does prior work and help others (I will pay back after I get better at it).

I divide my question into two parts:

1. Regarding Feedback

I got the following private feedback:

Add details and clarify the problem you’re solving

I have clearly mentioned it in my question:

English characters (a-z) with 0 or more exclamation marks in the end

In fact, the answer I got completely solves my problem. The author understood what I am trying to ask. I wonder why other felt that my question was not clear.

2. Regarding comments below my question

When I posted my question I didn't mentioned the code I had. I mentioned my solution (simply using iterative method) after user azro suggested to do so. But I wonder why a question like this one gets so many upvotes even though it's similar to my question at the time when I posed it (i.e., without code). I didn't mentioned my solution code earlier since it's straightforward and any person who has done "Introduction to programming" type course can find such a solution.

I just wanted to know some method using libraries of Python. Also I didn't have knowledge of regex in Python before, so it's very unlikely that it will strike in my mind that "Oh, it might be solved using a regex so let's search about regex and try to solve using it". Why does Stack Overflow assume that a user has knowledge of every domain (and where that domain is applicable)?

Note that user azro is very reputable person and I respect azro's comments below my question.

User azro mentioned in comments that "but how can we differenciate guys like you of guys that just paste their homeworks?". I think it's impossible to know if any user has posted his/her homework irrespective of how much prior work that person has done and any sort of help for homework would be unfair and thus Stack Overflow should stop suspecting because it's impossible to prove it person is asking a homework question. Stack Overflow is not the Internet police.

User azro mentioned in comments that "Stack Overflow is a question-and-answer site, not a code-writing service". I wonder then if every answer can be seen as a service. In my opinion this website exist because people can help each other (by volunteering). I am sure some answer on Stack Overflow would have helped azro too at some point of time. If one sees it as service then that person is free to not answer.

8
  • 2
    Yea, that edit really should've prevented the closure. The problem statement is clear, and you made an attempt at solving it yourself.
    – Cerbrus
    Commented Oct 31, 2021 at 7:44
  • 11
    It's re-opened and I've cleared up some of the noise in the comments. I think the key thing to take home here is that your original version of the post did look very much like a "write this for me..." which tends not to be received well - if you'd have included your attempt to start with then you'd have been fine.
    – Jon Clements Mod
    Commented Oct 31, 2021 at 8:05
  • 1
    As a side note, the one upvote that Tzlil answer has got is given by me. Few hours back I had -2 vote and I was not able to vote. If you upvote someone you give that person power on this website to further support those people who are answering. Downvote does no good. @JonClements I request if this can be considered on stackoverflow i.e not allowing downvotes instead allowing to give constructive criticism (or blocking user to ask for a week so that user can improve).
    – laser
    Commented Oct 31, 2021 at 8:08
  • 22
    @laser I can promise you without a doubt that such a change would destroy the quality of the site. Please see here, as well as the numerous suggestions both here and on MSE about removing downvotes, and the answers to those suggestions highlighting the reasons they would be bad for the site/network.
    – Daedalus
    Commented Oct 31, 2021 at 8:18
  • 3
    Yes, we are not internet police. Cops get paid. Commented Oct 31, 2021 at 15:12
  • @MartinJames Exactly. But some people want to do policing job here for free :(
    – laser
    Commented Oct 31, 2021 at 16:35
  • 2
    this was discussed many times before, see eg What do people get by focusing on doing only janitorial moderation?
    – gnat
    Commented Nov 1, 2021 at 9:31
  • Essentially this was a "how to" question. How to questions can be landmines on Stack Overflow as people tend to write them in a way that causes knee-jerk reactions. I wonder if someone has written a specific guide about how to make how to questions land well on Stack Overflow.
    – Gimby
    Commented Nov 2, 2021 at 10:40

2 Answers 2

9

Stack Overflow is a community; it has a history and rules (both formally established and unspoken). Entering a new community is always a bit tricky. Mistakes are going to happen, and sometimes it's hard to tell exactly where the misstep occurred. The most important thing is that we learn and move forward with shared experience.

I would like to give an answerers perspective to provide some insight into why I might choose to answer or not answer a question.

This is the initial version of the question:

How can I check if a string contains only English characters, exclamation marks at the end?

For example "hello!!" should return true, whereas "45!!","!!ok" should return false. The only case where it should return true is when string has English characters (a-z) with 0 or more exclamation marks in the end.

This is a difficult question to answer. There are many reasons for why answering this question could cause issues.

This initial post seems like what could be referred to as a "low effort question".

As has been seen the question garnered a generally negative response, this response can often extend to answers. Not that reputation is the end-all be-all of why people choose to answer questions, but others often avoid putting themselves in a situation where they can be downvoted by association.

Often new users are directed to How much research effort is expected of Stack Overflow users? which outlines quite a few points, but the one in particular that I'd like to draw attention to is this answer which quotes text that was previously in the official How do I ask a good question? guidelines

"Tell us what you found and why it didn’t meet your needs."

It is true that this guidance is no longer listed, but that does not mean that the community has stopped expecting this (which admittedly can be confusing to someone new). However, sharing what was tried can really provide a lot of context about the level of understanding the user has:

  • What kinds of things have you searched for?
  • What was close to working but didn't?
  • What didn't work at all and why?

Answers to these questions can point to exactly where the problem is and exclude all of the things that have already been attempted. We don't want to make more work for everyone

From the tour "This site is all about getting answers. It's not a discussion forum. There's no chit-chat." Extended conversation in the comments is not permitted.

The largest amount of space to provide information is the Question and Answer spaces. The comments are quite limited and a back-and-forth like:

"Have you tried `x`?"

         "Yes that didn't work because `y`." 

"Well what about `z`?" 

          "No `z` doesn't work because `q`." 

does not fit into the structure of Stack Overflow well. This may also apply to an answer. I have had quite a few experiences wherein I proposed a solution and I received a comment like: "Oh sorry, I forgot to mention I can't use x because y." This means that I spent time making an answer that does not solve the current problem. Typically an edit is made to the question which invalidates my answer (by adding a requirement that was not present in the initial). Now if I have the following options:

  1. update my question to account for the new requirement (which can involve entirely refactoring my answer)
  2. delete my answer and move on (which can be frustrating to both answerer and asker)
  3. continue a back-and-forth trying to figure out what other things were missing from the requirement (but by consequence generating a lot of "noise" in the comments)
  4. rollback the edit and let them know that it's generally not reasonable to edit the question after receiving answers in such a way that completely changes the requirements and invalidates existing answers (which is often leads to another source of conflict)

Depending on how I'm feeling I may choose to just avoid all of this by not answering the question if it's border-line, and/or vote to close until the question meets the minimum requirements.


A better structured question could have been something like:

How can I check if a string contains only English characters, exclamation marks at the end?

I am trying to test whether a string contains only English letters (a-z) with any number of exclamation points at the end. For example, "hello!!" should return True, but "45!!" or "!!ok" should return False. "45!!" should be False because of the numbers even though it ends with exclamation points. "!!ok" should be False because it does not end with exclamation points at the end and there are exclamation points at the beginning which is not allowed.

In my research so far, I came across How can I check if a string only contains letters in Python? which recommends string.isalpha() as show in this answer, but this does not work because it will only check for alphabetical characters and won't help determine if it ends with an exclamation point or not. There's an answer which uses a module re, but I'm not familiar enough to know whether or not I can modify this to fit my purposes.

This is my best attempt so far:

def fun(s):
    i = -1
    for i in range(0, len(s)):
        if s[i] == '!':
            break
        elif 'a' <= s[i] <= 'z':
            continue
        else:
            return 0

    while i < len(s):
        if s[i] != '!':
            return 0
        i += 1

    return 1


print(fun("hello!!"))

[Code snippet modified from Revision 2 of the question How can I check if a string contains only English characters, exclamation marks at the end? by laser]

I do not know for certain that this version of the question would have been better received. However, this is the question of someone who (in my mind) understands exactly what they're looking for, and has put in thought and time into solving it themselves.


Now let's address some of the other questions:

Are other questions actually well received or are they just old?

But I wonder why a question like this one gets so many upvotes even though it's similar to my question at the time when I posed it (i.e., without code).

This question How can I check if a string only contains letters in Python? is 8 years old with 170k views. It has a net score of 62 (+64 -2). Meaning (roughly) 0.036% of people who came across this question chose to upvote it. Questions that have been around for many years are not necessarily a good indication of how questions will or will not be received today. It is yet unknown if in 2029 this question will also have 60+ upvotes.

Assumptions about user knowledge

Why does Stack Overflow assume that a user has knowledge of every domain (and where that domain is applicable)?

There may be some users who have unreasonable expectations of the knowledge of an asker, but on the whole the expectation is that you share what you do know. We cannot determine if you are unaware of a technology or specifically avoiding it for some reason. The line added to revision 3 is super helpful because it lets us know that you're open to any and all possible solutions:

Following is my solution using iterative method, however I want to know some clean method having fewer lines of code (maybe by using some python library).

It also provides a clear direction for answers. This is a question about solving this specific problem in a more understandable and straightforward way.

Assumptions about Homework Questions

I think it's impossible to know if any user has posted his/her homework irrespective of how much prior work that person has done and any sort of help for homework would be unfair and thus Stack Overflow should stop suspecting because it's impossible to prove it person is asking a homework question.

It does not matter whether or not a question is Homework or not. "The Homework Question" is a type of question wherein someone dumps a problem onto the site without any effort and expects someone to provide them a complete solution. It's this type of behaviour that we try to discourage and has specific guidelines in the faq How do I ask and answer homework questions?. While this question may not be a homework question the first version is also certainly not not a homework question. Providing the things mentioned above and in the top rated answer of the faq we're just looking for some evidence of effort and clear guidelines for how to help.


Some final words: do not be discouraged. The current version of the question is fairly reasonable. It seems like this was an instance where a reasonable question was asked and a reasonable amount of effort was done to solve the problem, but those things just didn't get translated into the question itself.

I would also like to link to the Stack Overflow question checklist which can be very helpful to provide an exact framework to test whether or not the question has all of the components necessary.

1
  • Man, are there any stones left unturned? This can go into the FAQ, IMO.
    – Gimby
    Commented Nov 2, 2021 at 10:37
-6

Not to excuse either the downvotes or the votes to close, but your actual question is inappropriate for SO. Basically it is either asking for a library recommendation or for a code review. Library recommendations are off topic and code review requests would belong on https://codereview.stackexchange.com.

You could have asked about the idiomatic way to do this, which would have been on topic. Your question is also a semi duplicate of Check that a string contains only ASCII characters?, and I would have preferred to see it (or a better duplicate) used as the close reason when it was closed. As one of the answers suffice, but the questions are quite dissimilar, I would have left it open absent a good duplicate.

I think pointing the question towards codereview would have been acceptable, as would have been leaving it open and answering —- you didn’t know enough to ask a really good question, but if you had known more, you wouldn’t have needed to ask the question at all. More research might have found what you were looking for, but you didn’t know what to look for, so it’s impossible to say you would have have found it with more research.

Despite the closure and downvotes, I don’t find it a bad question. It might help someone else discover regular expressions some day.

PS while it’s obvious that not every programmer knows about regular expressions, it is something every programmer should know. It is nearly ubiquitous in the better text editors and a common solution to many problems.

6
  • 3
    The OP's question on main is not a library recommendation at all, it's a straight "how-to" question. In its original form, it didn't have any code, so it would have been inappropriate on Code Review. I can't speak for whether it would be on-topic on Code Review with the additional attempt, but I doubt it. Even with the attempt though, it's not a library recommendation.
    – cigien
    Commented Nov 1, 2021 at 0:57
  • @cigien: 3rd version says “Following is my solution using iterative method, however I want to know some clean method having fewer lines of code (maybe by using some python library).”, The OP wanted either a recommendation for a library that does it better or recommendation on how to make the code better. It didn’t start out that way, but given that is how it ended up, I’m fine saying that was the actual question. The OP didn’t quite know how to express what was wanted at first.
    – jmoreno
    Commented Nov 1, 2021 at 1:05
  • 1
    Even in that revision, it's quite a stretch to call it either a library recommendation, or code review question. It's also quite clearly not the OP's intent to ask the question like that; they were coerced into doing so by the comments on their question. The question was a "no-effort, how-to" question, and I'm confident it was closed for that reason, not because it was a recommendation request, or a review request.
    – cigien
    Commented Nov 1, 2021 at 1:14
  • @cigien: given that the OP has a working solution, I think calling it a “no-effort, how-to” is wrong. The OP clearly has some idea that this type of thing should be short and easy, but doesn’t know enough to give it a name. The question as originally written wasn’t explicitly asking for a library recommendation, but given what was there and how it ended up, I feel that is what was actually being (clumsily) asked for. You call it coercion, I call it eliciting further details.
    – jmoreno
    Commented Nov 1, 2021 at 1:57
  • 3
    Please do not point this kind of question to Code Review; that site is for seeking general feedback on working code. If somebody posts on Stack Overflow saying something like "here is my code, which works, but is there any way to improve it?" then you should point them at Code Review. Otherwise, don't.
    – kaya3
    Commented Nov 1, 2021 at 3:49
  • 1
    @kaya3: That is a exactly the most valid interpretation of version 3 of the the question. The code is working and the OP wants to know if there is a “cleaner” way of doing it. The OP doesn’t know if that cleaner way is a 3rd party library, a standard or a a language construct. The given code could be cleaned up and made more pythonic, without using the re module, but the existence of regular expressions in general is what the OP was fumbling for. There is a disconnect between what was asked and what was wanted.
    – jmoreno
    Commented Nov 1, 2021 at 4:14

You must log in to answer this question.

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