Skip to content

Tag: python

how to prevent regex matching substring of words?

I have a regex in python and I want to prevent matching substrings. I want to add ‘@’ at the beginning some words with alphanumeric and _ character and 4 to 15 characters. But it matches substring of larger words. I have this method: And the example is : And the answer is : As you can see, it puts

Print output for data list python

I am trying to print an output but I just can’t figure out method. and I am trying to get an output like this: output I don’t really understand array and I have tried a few methods but failed to output it as the image shows. If possible, I would need some explanation too because I want to learn ra…

Insert error in a Mysql query Flask web app

My app.py code : This is the error I get : I am using python 3.10.2 and flask 2.2.2 in my virtual environment. And I am using Visual Studio IDE. It seems like I am doing something wrong in the MYSQL query. can you guys tell me what am i doing wrong here. Answer You are missing a closing bracket

why my model does not learn? Same on every epoch (Pytorch)

Output 0 – training loss: 0.0837 | test loss: 0.0806 100 – training loss: 0.0433 | test loss: 0.0431 200 – training loss: 0.0426 | test loss: 0.0425 300 – training loss: 0.042 | test loss: 0.0419 400 – training loss: 0.0414 | test loss: 0.0414 500 – training loss: 0.0408 | …

Django return, Profile matching query does nor exit

I’m new to Django and I’m working on an Instagram clone project as a beginner. And I didn’t get this error. I imported the user The Profile class is created here, and it is successfully migrated. and this is my views.py someone please answers this where is my mistake? Answer check in your da…

Python – Converting urllib to requests

I’m writing code to access the MS365 API and the Python code example uses urllib. I want to instead use requests but I’m not sure how urllib translates into requests as my attempts of doing so have failed. The code example can be found here: https://learn.microsoft.com/en-us/microsoft-365/security…

How to understand this loop program in Python

I’m trying to polish my Python skills and this made me confused. Here’s the code: I don’t understand what the count does. Answer Let’s comment up the code with explanations of what each line does and then examine the output. So, based on all that, what should we expect the output to be…