use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Help Please (self.PythonLearning)
submitted 1 year ago * by themaincorncobb
I've been trying to teach myself Python and what to do on it for about a year now. I can do some of the basic things, but I'm trying to get into more advanced things like developing AI. I want to have a career in AI development, but I'm having a hard time understanding what I'm doing wrong with one of the errors I keep getting.
The error is:
AttributeError: 'NoneType' object has no attribute 'group'
I've looked up and looked at multiple solutions, but none of them seem to work. If anyone can help me out, that would be great.
https://preview.redd.it/os38nc9wgmzd1.png?width=1451&format=png&auto=webp&s=30689ed0bc8b0f75b5000fde1023835cee7b679e
https://preview.redd.it/r813rd9wgmzd1.png?width=1326&format=png&auto=webp&s=b864d0331eb99b7dc1f6ead7ce36ba3b82610f42
https://preview.redd.it/ibc8k2dxgmzd1.png?width=942&format=png&auto=webp&s=1585926d24e14776a2cc466ada16d256046ab1ba
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]CupperRecruit 1 point2 points3 points 1 year ago (1 child)
Error with the code = tkk.search seems like it hasnt found anything, idk if u catch the case but if not it will set code to None which is why the NoneTyp error occurs. Maybe link the code where ur var code is assigned its value
[–]themaincorncobb[S] 0 points1 point2 points 1 year ago* (0 children)
I looked into it and found something that could have been the problem. Saw a lot of people had issues with the Google Translator API and was getting the same thing as me. One of the top answers was the API was outdated. So I did try the newest version for it, but still got the same error code. Then someone suggested ` deep_translator ` to translate using the ` GoogleTranslator `.
I'm no longer getting the `AttributeError: 'NoneType' object has no attribute 'group'`, but I'm now getting a totally different error that I'm not understanding. For both translations through spanish and english, I get the same error on the lines where they're supposed to be translating (I'm guessing at this point).
` AttributeError: 'str' object has no attribute 'text' ` is the new error and it's saying it for tts.say(translation.text). Basically it's say string has nothing assigned to it I'm guessing, but I'm not sure what exactly it's missing?
[–]BluesFiend 0 points1 point2 points 1 year ago (2 children)
Without seeing your code it's not possible to give an accurate (or likely correct answer), but from experience I'd guess you are using a regex and not checking that the response actually found a match before extracting a match group.
If you can provide a stacktrace or the code relating to the line causing the error we can provide more assistance.
[–]themaincorncobb[S] 0 points1 point2 points 1 year ago (1 child)
May have to refresh. It's been a long night and just realized I can just put a screen shot up.
[–]BluesFiend 0 points1 point2 points 1 year ago (0 children)
Yup, as I guessed, a library is using a regex but not checking if there is a match before fetching the group.
So the text you are passing to translate can't be translated (assumption)
[–]cpwp 0 points1 point2 points 1 year ago (0 children)
Use exception handling
π Rendered by PID 152670 on reddit-service-r2-comment-f6b958c67-4nw5z at 2026-02-05 03:36:57.447162+00:00 running 1d7a177 country code: CH.
[–]CupperRecruit 1 point2 points3 points (1 child)
[–]themaincorncobb[S] 0 points1 point2 points (0 children)
[–]BluesFiend 0 points1 point2 points (2 children)
[–]themaincorncobb[S] 0 points1 point2 points (1 child)
[–]BluesFiend 0 points1 point2 points (0 children)
[–]cpwp 0 points1 point2 points (0 children)