0
Need help
Line 17 what is the need for i != 0 When checking whether the string contains a hyphen https://code.sololearn.com/c952c16Nzl2i/?ref=app In my opinion just c == "-" is enought
2 Answers
+ 4
Hello stephen haokip
To allow negativ numbers.
"-456" is a number. If you just say return false when c == '-' then you're program would only work for positive numbers.
+ 3
A hyphen connects words/word parts. So it can by definition not be the first character of a string. So if a string begins with a "-" it can be a minus or a bullet point, but not a hyphen.