Length issue in Python3 - python-3.x

I am taking an Ethical Hacking class, and my lab for the week is trying to crack passwords created by our professor. For this specific challenge, I used a 64 bit decoder to translate his string in his code, and have found the way to solve the problem.
The issue is when I run the equation found in the code, I run into an error in Python. I'll attach an image for clarification. I do know that length is typically found using len() but I don't know how to use that in this context. The part giving me issues is the [chunk2.length-1].
I was informed to add the errors I am receiving so here it is:
you = chunk1[2+1]+d[1+1]+h[3]+chunk2[chunk2.length-1] AttributeError: 'str'
object has no attribute 'length'
Any help provided would be great, thank you guys.

I changed chunk2[chunk2.length-1] to chunk2[-1] and that solved my issue.

Related

Could not find QtWebEngineProcess.exe

I was building an application(Equation solver) in PyQt5 which contains two frames.
The first frame works just fine but the 2nd frame contains a QWebEngine widget which worked fine when I directly ran it from the code in my code editor but when I converted into an .exe
file using cx_freeze, on running the second frame I get an error saying "Could not find QtWebEngineProcess.exe" .
I did a little bit of digging myself and found out that its quite common actually, even found a question similar to this in stack overflow : here.
I tried adding the qt.conf file but to no avail, the error still persists.
I am at a loss here, been working on this for so long and now this error really ruined the flow.
I would be very grateful for any kind of help.
Thanks.

Issue with viewing data transformation with PyTorch

I am currently trying to process data for a simple network. This is the code I entered:
Screenshot here
I keep getting this error message but can't find any syntax problems or anyone else with this issue, I'm guessing it's something to do with my vienv because I've seen tutorials of people with no issues and that exact code. It's possible I haven't imported a package into my IDE and I am using anaconda and PyCharm if that helps.
Anyway, this is the error message I keep getting.
Error Message
You need to use transforms.ToTensor() instead of transforms.ToTensor when passing to transforms.Compose.

Does the sagemaker official tutorial generate an AttributeError, and how to solve it?

I'm following the AWS Sagemaker tutorial, but I think there's an error in the step 4a. Particularly, at line 3 I'm instructed to type:
s3_input_train = sagemaker.s3_input(s3_data='s3://{}/{}/train'.format(bucket_name, prefix), content_type='csv')
and I get the error
----> 3 s3_input_train = sagemaker.s3_input(s3_data='s3://{}/{}/train'.format(bucket_name, prefix), content_type='csv')
AttributeError: module 'sagemaker' has no attribute 's3_input'
Indeed, using dir shows that sagemaker has no attribute called s3_input. How can fix this so that I can keep advancing in the tutorial? I tried using session.inputs, but this redirects me to a page saying that session is deprecated and suggesting that I use sagemaker.inputs.TrainingInput instead of sagemaker.s3_inputs. Is this a good way of going forward?
Thanks everyone for the help and patience!
Using sagemaker.inputs.TrainingInput instead of sagemaker.s3_inputs worked to get that code cell functioning. It is an appropriate solution, though there may be another approach.
Step 4.b also had code which needed updating
sess = sagemaker.Session()
xgb = sagemaker.estimator.Estimator(containers[my_region],role, train_instance_count=1, train_instance_type='ml.m4.xlarge',output_path='s3://{}/{}/output'.format(bucket_name, prefix),sagemaker_session=sess)
xgb.set_hyperparameters(max_depth=5,eta=0.2,gamma=4,min_child_weight=6,subsample=0.8,silent=0,objective='binary:logistic',num_round=100)
uses parameters train_instance_count and train_instance_type which have been changed in a later version (https://sagemaker.readthedocs.io/en/stable/v2.html#parameter-and-class-name-changes).
Making these changes resolved the errors for the tutorial using conda_python3 kernel.

CS50 Pset7 Finance

I have question for my CS50 Pset7 finance project. I don't know where to ask this question, so I seek help here. I just finished the register part, however, when I try to test the website, I registered successfully, however, when I try to log in, I got a strange error which I think is because of my way of using hash is not correct. So I got the error TypeError: invalid method '' for security.py", line 186, in _hash_internal, and I can see my hash value like $6$rounds=656000$OiBqI/lX2GqhI8be$G. I found in the API that the schema support has been removed. I'm wondering how should I use hash method other than pwd_context.hash(request.form.get("password")). Any advice will be appreciated.
Use generate_password_hash() to replace hash() will work. Don't forget to remove or update the existing entries inside your db since the old hash will cause error.

Output generated is different with output in NLTK tutorial

Today I start to learn Python because I need to use NLTK in my assignment. In order to learn it, I follow the tutorial in this site http://www.nltk.org/book/ch01.html. However, when I run the programme in Python interpreter, the output produced is not same with what has been shown in the website and I have no idea on what thing that this output wants to tell me.
(Below is the picture of the output:)
Input: >>> from nltk.book import *
Output (After I hit 'Enter'):
So now my questions are what is the error about and if there is a way to solve it, then what should I need to do?
Thanks for looking into my problem.
This appears to be a known bug with nltk and Python 3. It seems to have been fixed within the past two weeks, but I expect you'll have to wait until there's a release that contains the fix. You could try installing from source.

Resources