These are chat archives for Codewars/codewars.com/kata-solving-help

14th
Jul 2018
chutetearer2013
@chutetearer2013
Jul 14 12:26
Hello to all - didn't know there was this chat room - nice :)
Is there a known problem with https://www.codewars.com/kata/get-a-users-honor?
Tried in python 2 and 3, and both give server errors: urllib2.HTTPError: HTTP Error 500: Internal Server Error and urllib.error.HTTPError: HTTP Error 500: Internal Server Error.
Donald Sebastian Leung
@DonaldKellett
Jul 14 13:01
@chutetearer2013 I haven't solved that Kata myself yet but I've heard it's about scraping (a technique that apparently does not involve querying the CW server)
DanL12186
@DanL12186
Jul 14 13:02
It is scraping
Also no, the kata works last I checked
It's possible the server's having issues atm
Oh my mistake... I did get the year a codewarrior joined, not get a user's honor.
I was actually annoyed he was allowed to make two separate kata doing basically the same thing
you're using import urllib.request ?
Darshan
@darsh97
Jul 14 16:04
chutetearer2013
@chutetearer2013
Jul 14 19:44

thanks for your answers. Yes I am using urllib.request (urllib2 in python 2). Both versions work in CW and give the correct answer but when I submit with "attempt" the following error is displayed:

Traceback (most recent call last):
File "main.py", line 30, in <module>
test.assert_equals(get_honor('dpleshkov'), control('dpleshkov'))
File "/home/codewarrior/solution.py", line 5, in get_honor
with urllib.request.urlopen(url) as f:
File "/usr/local/lib/python3.4/urllib/request.py", line 161, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.4/urllib/request.py", line 470, in open
response = meth(req, response)
File "/usr/local/lib/python3.4/urllib/request.py", line 580, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/lib/python3.4/urllib/request.py", line 508, in error
return self._call_chain(args)
File "/usr/local/lib/python3.4/urllib/request.py", line 442, in _call_chain
result = func(
args)
File "/usr/local/lib/python3.4/urllib/request.py", line 588, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: Internal Server Error

Will have a look at http://docs.python-requests.org/en/master/

hobovsky
@hobovsky
Jul 14 20:30
Does your solution work when used in 'Example tests' section? If it works with example tests, but not with final tests, then I'd guess that reference solution, for some reason, stopped to work :(
error256
@error256
Jul 14 20:47
User "dpleshkov" doesn't exist, so it's a kata issue.
hobovsky
@hobovsky
Jul 14 20:52
python question, guys: how can I achieve in python thing similar to following javascript expression: let value = m[3] || ""; - I mean the "assign '' if m[3] does not exist in the array" part
hobovsky
@hobovsky
Jul 14 20:57
okay, got it I think, I still forget that I sohuld use or instead of ||
TorkelV
@TorkelV
Jul 14 20:58
Not really the same but.. return "" if len(m) <= 3 else m[3]
Dont you get index out of range with m[3] or "" ?
hobovsky
@hobovsky
Jul 14 21:02
ah you are right, I was mistaken because m[3] actually was in bounds, but empty
ok so I need a conditional expression then
if index is out of bounds
Souzooka
@Souzooka
Jul 14 21:03
Hah, I forgot that that kind of short circuiting relies on out of bounds indexes not throwing an exception
chutetearer2013
@chutetearer2013
Jul 14 23:45

Even just:

def get_honor(username):
print(username)

bugs. It prints the right name and crashes with a similar message as above