Questions tagged [python]

Code using the python language.

Filter by
Sorted by
Tagged with
0
votes
0answers
18 views

Final Project - Get sql to work html, python and flask

On my website for my final project I am able to enter the user info on the website, but the information is not being inserted into the sql table. I feel that I am not understanding something very ...
0
votes
0answers
14 views

CS50W Project 4 / Network - NoReverseMatch

I'm currently on the last project for CS50 Web called Network and am stuck on the Follower spec. I'm trying to get the url in the Following tab to bring you to the profile of the specific user that's ...
0
votes
0answers
15 views

CS50 Web Track - Finance: OSError: [Errno 99] Cannot assign requested address

I'm trying to create a standard 'forgot password' feature for my web application. The issue is, when the user types in their email address and clicks submit to receive a token after which they can ...
0
votes
0answers
5 views

JavaScript functionalities not applied when JavaScript code written in an external .js file for a flask application

I'm working on project2 of CS50's web programming using python and javascript. I've made a .htm file and I need to write some javascript code for the page. I first wrote the code in an external file ...
0
votes
0answers
13 views

Flask-WTF: input field rendered based on the user's selection

I'm trying to make a form where the user logs an action they've done. Because there were too many actions, they are now split into categories and then, based on which category the user chooses, the ...
0
votes
0answers
53 views

PSet 6 DNA: Not able to match variables to dictreader names

I've mostly completed my code for PSet 6, except for the last part where I need to match up the values against the list of names. I know how to get the maximum occurances of the STRs and state the ...
0
votes
1answer
17 views

CS50 Final Project / Personalized HTML path

I'm on the Final Project for CS50 and trying to make a simple website to type in General Tasks and get information within different Subjects. I decided to use Flask over Django, however now I'm stuck ...
0
votes
0answers
58 views

I'm stack with dna (pset6). can you please help me?

I have divided my code into three main pieces: 1- open the CSV file and read its contents into memory and open the DNA sequence and read its contents into memory 2- compute the longest run of ...
0
votes
1answer
46 views

DNA: Errors in sequences.3 and 18.txt

I have worked hard on writing codes for DNA. Everything works except for sequences/18.txt, which returns "Harry" instead of "No match". The problem still exists in spite of several ...
0
votes
0answers
25 views

DNA.py error: 'TypeError: unsupported operand type(s) for *: 'NoneType' and 'int''. It passes all but 2 of the tests

DNA.py is nearly finished, but it is failing the tests with sequence/15.txt and 16.txt. This is the error message: ~/pset6/dna/ $ python dna.py databases/large.csv sequences/16.txt Traceback (most ...
0
votes
0answers
14 views

pset6 Readability Python: Calculated grades too high

My code below returns incorrect grades. Often it is even two grades higher than it should be. Any ideas where is the mistake? letters = words = sentences = 0 for char in text: if char.isalpha(): ...
0
votes
0answers
36 views

TicTacToe task: PyGame display not rendering

For some reason, the PyGame TicTacToe display is not showing. It just hangs at this: This is the runner.py: import pygame import sys import time import tictactoe as ttt pygame.init() size = width, ...
0
votes
0answers
21 views

i dont know why i got error in the cs50 knight puzzle

from logic import * AKnight = Symbol("A is a Knight") AKnave = Symbol("A is a Knave") BKnight = Symbol("B is a Knight") BKnave = Symbol("B is a Knave") CKnight =...
0
votes
1answer
12 views

Final Project - if statement with regex not working?

Working on my final project and I'm stuck trying to edit user input. The below code should take the first string in a list and check if it's numeric. If it is, great, that's what I want, otherwise, I ...
0
votes
0answers
6 views

I'm wondering how to import Django through my Powershell and how to active Django in my PythonPath

I'm trying to import and active Django in my pythonpath, but I still have this message show up in my manage.py tab on VSCode (I'm using Windows 10 and am finding a lot of Linux inputs): ""&...
0
votes
1answer
14 views

'>' not supported between instances of 'tuple' and 'float'

First I checked for correlation: pear_cor = df.corr(method='pearson') pear_cor Now I have to go through the data and check for the following condition: for val in pear_cor.items(): for x in val: if ...
0
votes
1answer
161 views

Struggling with PSET6 DNA

I've been doing this for quite some time now, but I'm struggling to get the appropriate output. In the below code (which is incomplete as of now, but the main pieces are all on the board), I'm not ...
0
votes
1answer
17 views

Keyerror Won't Go Away

I keep getting a key-error in pset7, Houses: Traceback (most recent call last): File "import.py", line 24, in <module> names = cutting(row["name"]) KeyError: 'name' ...
0
votes
1answer
26 views

Finance index.html is not rendering values from my index function

I'm having some issues trying to render values on my index.html page. In my index function, I created a dictionary of values from my transactions table to grab each record of my share symbols, share ...
0
votes
0answers
72 views

how do I perform a search

This is project one for wiki and I am stuck this is my last thing to do. below are screenshots of the views.py, util.py and template. We are suppose to use the functions from util.py(This is the last ...
0
votes
1answer
12 views

Why updating a dictionary is not working?

for row in rowsList: if row['middle'] is None: row['middle'] == "" print("{} {} {}, born {}".format(row['first'], row['middle'], row['last'], row['birth'])) Where ...
0
votes
1answer
108 views

Pset6 DNA Not matching to names in the database

The print statements seem to turn out what I hoped for up until trying to compare the STR counts to the database STR counts. I would just appreciate any pointers of where I'm going wrong thanks. ...
0
votes
1answer
17 views

Python - for loop not being executed, leading to NameError of variables defined in the loop

It's a simple Python program to find the number of primes until a certain number. The for z in range(1,y): loop does not execute, but rather execution jumps to the print(count," Pr...) statement ...
0
votes
0answers
19 views

I keep getting invalid syntax at else. I am trying to redirect a page

here is the code. I keep getting invalid syntax at else. Can someone explain why and help please.
0
votes
0answers
27 views

I keep getting - TypeError: unhashable typ

can't get page to redirect please help. I keep getting the error TypeError: unhashable type: 'dict' at line: return HttpResponseRedirect (reverse("encyclopedia:index", { "entries":...
0
votes
3answers
98 views

PSET6 Mario Python

I have been experiementing with this code for a couple hours and have come across an issue with each implementation. I can no longer put in any time at the moment so I figured I would go ahead and ask....
1
vote
1answer
79 views

CS50 Houses : Output is correct in my console but error in check50

I am working on the CS50 course by Harvard EDx. The output for CS50 - Houses is correct in my console. However, check50 which is validates and evaluates the response gives an error. I have checked the ...
0
votes
0answers
97 views

PSET6 DNA [SPOILER] Refactor

I have solved the problem however is there anyway to optimize this further? Also, how do I judge the time-space complexity of the same? import csv from sys import argv, exit from csv import reader, ...
0
votes
0answers
17 views

I have been trying to fetch book reviews from Goodreeads API

I got this sqlalchemy.exc.ProgrammingError sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) can't adapt type 'RowProxy' while trying to fetch book reviews from Goodreads API with the ...
0
votes
0answers
80 views

Confused about DNA in pset6

I've just started DNA, and I've got what seems to be a working algorithm to see if the count of the STRs in the database and sequence are the same, but it does not seem to be working. I've been a bit ...
0
votes
0answers
23 views

i dont know why i'm getting 45% when it looks like it's working

while True: n=int (input("enter height: ")) if n>=1 and n<=8: break k = 2 * n - 2 for i in range(0, n): for j in range(0, k): print(end=" ") k = k - 2 for j in ...
0
votes
0answers
11 views

Ive been getting a syntax error for this Python code. Id appreciate If someone could help me

This is from a python course by mosh The code is this -> import pandas as pd from sklearn.tree import DecisionTreeClassifier from sklearn.model_selection import train_test_split from sklearn....
0
votes
0answers
96 views

cs50 pset6 DNA, minor differences in counting STRs |Spoiler entire code included|

My code counts STRs for some people correctly, but for others the difference is very small. For example for python dna.py databases/large.csv sequences/5.txt expected output is Luna, whose STR counts ...
0
votes
0answers
44 views

PSET 6 - credit, pythonic or not?

I didn't do credit for problem set 1 (I chose less comfortable) so I don't know what the C implementation was. I was wondering if you guys think this is too C-like or if it's okay for python code. Any ...
0
votes
0answers
8 views

CS50w flack (chat) project: channel user list stops updating after a while, can't understand why

This is a weird one, so I've recorded a short video to better illustrate the problem. As an additional feature to my chat app I have a panel on the right that displays the users currently on the ...
0
votes
1answer
123 views

PS6 - DNA (Python) Weird problem counting STRs

Which part of the problem are you working on? I am at a very early stage of the problem, trying to scan a specific sequence for STRs, counting how many times they show up and storing this count as a ...
0
votes
2answers
92 views

Finance: UNIQUE constraint failed: users.username

I've been struggling with this for days. Ignore the '1234' hardcoded into the "insert into" line, just using that to isolate problems. The problem I'm facing is with the username being ...
0
votes
1answer
36 views

Finance - Missing Value For Placeholder

As far as I can tell, I have the value set - username = username. Am I missing something stupid here? Code: @app.route("/register", methods=["GET", "POST"]) def ...
0
votes
0answers
7 views

Does __tablename__ create a new table for each object? And what is .query.all? Is it a method?

I am really confused In CS50'S Web Programming with Python and Javascript-ORMs and APIs. There is weird syntax like class.query.all. What is Its definition (a method, a function, etc).
0
votes
0answers
43 views

CS50 PSET6 Credit

I am working on the PSET6 CREDIT of cs50 in Pyhton. I can make my program work properly. When I input 378282246310005 as a credit card number, the output should be AMEX. However, no matter the input, ...
0
votes
0answers
54 views

Error in Python--Cs50 week 6

I'm just starting cs50's week 6 in python. I copied a small program written by David in the lecture to run in my cs50 IDE, but I'm getting a strange error. I believe the error is about the get_string ...
0
votes
1answer
231 views

PSET6: DNA returns “no match”

import csv import sys def maxrepeats(sequences, substring): # calculate maximum consecutive frequency for each STR repeats = [0] * (len(sequences)+1) for i in range(len(sequences)-len(...
0
votes
1answer
35 views

RuntimeError: missing value for placeholder (:name)

all! I'm doing the final project, and I have a form whose contents I'm trying to submit to a database. My python code is: @app.route("/Contact.html", methods=["GET", "POST"]) def Contact(): if ...
0
votes
1answer
73 views

pset6 DNA - range() not working as expected

DNA was a breeze until I got to the part where I have to check the dna sequences for patterns. Regardless of wich file I pass to the program it always detects only 1 repetition for every pattern. ...
0
votes
1answer
68 views

What are the requirements for Week 6 Mario (more)? My code works but the grade book shows only 96% completeness

I tried two different variations but both reach 96% completeness code 1: from cs50 import get_int while True: height = get_int("Height: ") if height < 9 and height > 0: break ...
0
votes
0answers
84 views

pset7/houses: db.execute(“INSERT”) fails to export data to students.db

I am using pandas to read in the csv file, since I'm familiar with dataframes from R. But I think that may not be the issue here, which is that db.execute fails to export data to students.db. The code,...
0
votes
0answers
85 views

PSET6 - DNA - Code works for small database, but not large

I believe that the issue comes from my 'sequencing' function. When I run the small database, everything works, however, when I run the large database, the counts of specific STRs are incorrect. I'm ...
0
votes
1answer
129 views

Problem with path reversing in CS50 AI -> Degrees

I have a problem in my code that reverses the path my BFS search algorythm takes. The first project in the CS50 Introduction to artificial intelligence is called degrees and finds a path from one ...
0
votes
0answers
18 views

Couldn't run the code

I'm trying to run the below code in cmd but I couldn't, it is saying " Traceback (most recent call last): File "list.py", line 3, in from sqlalchemy import create_engine ModuleNotFoundError: No ...
1
vote
0answers
52 views

PSET6: dna.py, updating dictionary

I'm struggling with Python, specifically adding/updating keys and values in a dictionary. This is my code so far (I know it's probably far from perfect, this is my first time working with Python, ...

1
2 3 4 5 6