Questions tagged [python]

The tag has no usage guidance.

0
votes
1answer
18 views

Pset8 Finance problems with SQLite inserting into a table

Inserting into a table in finance.db fails. I'm able to run the sqlite3 command via cli without errors and populate the table with the debugging snippet command: INSERT INTO history (date, symbol, ...
0
votes
1answer
21 views

pset8 New errors without changing any old code [duplicate]

I've been working hard on pset8 lately and making great progress. I was busy and didn't get to work on it for about a week. I'm now getting errors that I didn't get before, and as far as I'm aware, I ...
0
votes
1answer
16 views

Stuck on Caesar, analyzing command line arguments

I've posted my code blow. I'm supposed to check if the 2nd command line argument (the key) is an number or not, and if it is, print it out as an integer. I'm having two issues: I get an error ...
0
votes
1answer
10 views

How to pass value from HTML to python?

I'm setting up a new project in python ,and want to setting up a web pageresturant.html using FLASK , this code in html get the selected value from drop down box when button is clicked ,how can i pass ...
0
votes
1answer
13 views

PSET 6 [Similarities - less] How is the compare file accessed in this problem since it is not imported to application.py

(Dont be intimidated by length of code chunks, I included all of my guess as to what's going on, so most of it is just stuff to skim over) The folder similarities contains static and template folders ...
0
votes
1answer
23 views

Cannot run Flask - TypeError

Whenever I try "flask run" I get this error in the IDE. I have no idea what the problem actually is. ~/workspace/pset7/survey/ $ flask run * Serving Flask app "application.py" (lazy loading) * ...
0
votes
1answer
17 views

python pset1 cash problem

Trying to solve pset1 cash less comfortale with python. Whats my mistake as I cant figure it out. Lets say I add 5.16 as cash owed that is 20*0.25+1*0.1 +1*0.05 +1*0.01 , 23 coins total used. ...
0
votes
0answers
28 views

Instance of 'scoped_session' has no 'commit' member

I'm working on the project1 from cs50web course. Getting the following problem using flask and SQLAlchemy: "Instance of 'scoped_session' has no 'execute' memberpylint(no-member)". I use Ubuntu 18....
0
votes
0answers
12 views

not supported between instances of 'tuple' and 'float' podrían decirme por que sale este error en este alforitmo?

not supported between instances of 'tuple' and 'float' podrían decirme por que sale este error en este alforitmo? def mayor(): diccionario=dict() archivo=open("datos.csv","r") print("...
0
votes
1answer
21 views

pset 7 survey: trying to redirect to /sheet returns invalid syntax error

For part of CS50's survey problem from pset7, I'm supposed to redirect from a route that checks if the user has entered in all the survey's fields / appends the values to a csv file --> a route that ...
0
votes
1answer
25 views

CS50 Bleep Incorrect Output

I am encountering a problem in CS50 Bleep. When censoring the message, the censored message consists of only one * for the entire word, rather than the length of the word. Here is my code: from cs50 ...
0
votes
1answer
16 views

PSET 6: Sentimental [Mario.py(less)]: How exactly do I “reject input” in Python as specified in check50?

this is my first time posting on here and I'm trying to not break any rules but sorry if I do. So, I followed the specification to make mario.py ( they are the same ones for mario.c ) in Sentimental ...
0
votes
1answer
16 views

CS50 finance/sell: DB not updating cash

I am currently working on the finance assignment however I am facing some difficulties updating the cash variable into my users database. All other database updates work fine but when it tries to ...
0
votes
1answer
13 views

CS50 Pset6: cash.py not returning number of coins used for change

Below is my code for pset6 of CS50, in which the user is prompted for an amount of change in the form of a float, which is converted into cents (e.g. 1.25->125), and the fewest coins needed to make ...
0
votes
1answer
14 views

Pset6 credit python Problem

I try to convert my Credit Solution from C to Python now. But on Line 19 ( doubleCheck = ccNumber[i] * 2 ) i always get the error "TypeError: 'int' object is not subscriptable"! How can i fix this? ...
0
votes
1answer
67 views

pset6 bleep: Problem with difference between list and string

I assume that I have the following problem: I create a list for the banned words and although a list with the text input. Then I want to compare both list. But when I create the list of the user ...
0
votes
0answers
37 views

Crack(python) very slow

from sys import argv from crypt import crypt from string import ascii_letters from itertools import product if len(argv) != 2: print("Incorrect number of arguments") exit() hashed_p = argv[1]...
0
votes
1answer
97 views

AttributeError: __enter__

I defined a table in python using sqlalchemy but when i try to create it this error appears
1
vote
1answer
119 views

PSET6 CRACK (python)

I'm stuck on Crack (in Python). I wrote the following code, which I think should cover every case, however it runs for hours without finding a solution. Any thoughts/advice are appreciated. from sys ...
0
votes
2answers
55 views

Can't Connect Python Flask With PSQL Database

every time i try to make connection between python and PSQL this error disappear ?
2
votes
1answer
91 views

CS50 Finance: Register unique username (/check) problem: pythion GET function not working

I am working on the new /check additional on the Finance problem. I am trying to prevent the register form from being submitted when the username is already taken, is empty, or is just one character. ...
0
votes
0answers
36 views

Issue with CS50W's Project2 - submitted text not passed to chat window

I have a problem regarding passing posted messages into the proper field and presenting them to the user. The app is supposed to transfer the text submitted in "messenger" into the "messages" so to ...
1
vote
1answer
43 views

pset7 similarities: c-style loop vs generator

I am working on the similarities helpers.py. On checking check50, I found that the generator below does not work as intended, where input is ('This is one. This is two. This is three. This is two. ...
0
votes
0answers
24 views

How to integrate handlebars(written in raw javascript) into django templates

Please, I'm still rather new to handlebars templating, my handlebars template works perfectly with just html files, but when I try to render the page containing the handlebars template, I get all sort ...
1
vote
1answer
46 views

problem with pset6 python credit

Below is my code: [hidden code] output is: Enter the card number: 378282246310005 firstTwo 37; firstOne 3; cardlen 15 MASTERCARD note: it shows MASTERCARD instead of AmEx..Why?
0
votes
1answer
29 views

PSET7 variable not defined for sql statement

This is a chunk of my code from buy: if total_cost <= cash_balance[0]["cash"]: user_id = session["user_id"] cash_remaining = cash_balance[0]["cash"] - total_cost #db....
1
vote
1answer
31 views

Python Caesar not working for mix case etc

I've pretty much gotten my program to work 90% successfully! But, it does not produce the correct outcome for mix case or spaces/symbols. I've tried a number of different methods to no avail. At the ...
0
votes
1answer
85 views

Final Project - Problem uploading files to IDE folder

Update: Does anyone know hot to get the folder's absolute path? It isn't ~/workspace/fp/documentos/ or any of it's variations, such as /workspace/fp/documentos/ or workspace/fp/documentos/. It seems ...
0
votes
1answer
13 views

Why can't I break out of this while loop in python 2.7?

I've used a very similar loop in the past and had no issues. Here is the code: while(1): # Read the file file = open("db.csv", "r") # Get a line from the file line = file.readline() ...
0
votes
1answer
19 views

PSET8 invalid sw.

When I am trying to use the search bar, the autofill just gives me " , , " and when I click on that suggestion the console tells me "invalid sw". After reasearching the problem a bit, everyone seems ...
1
vote
1answer
155 views

PSET6 Similarities (more) Could Not Read File1

I am working on the distance function in pset6 similarities (more comfortable). When I run ./score cat ate, it gives me the error "could not read cat". I copied my code to another tab to test out my ...
0
votes
1answer
45 views

Project 1 Stuck on WHERE clause for Searching Books

I am working on Project 1 for CS50W on EdX. I am building the book search Flask app. My problem is with building the SQL SELECT statement utilizing the WHERE clause depending on the search fields. I ...
0
votes
1answer
1k views

Unable to run Flask App using Anaconda Prompt.Do Anaconda support Flask?

I am using Anaconda for editing and running scripts. In Anaconda prompt/command prompt, when I type this command : export FLASK_APP=application.py I am getting the error: "'export' is not recognized ...
0
votes
0answers
34 views

Mario.py works but gets different check50 results each time without changing a thing in the source code

Can someone please point out what's wrong with my code? from cs50 import get_int def main(): print("Height should be a positive integer between 0 and 23.") # a "do-while" loop to recieve a ...
0
votes
1answer
62 views

Should my distances function return the matrix in PSET6?

I'm working on the 'more comfortable' version of Similarities in PSET6. When I execute ./score wordone wordtwo, the IDE responds: 'Could not read wordone'. I initially thought the issue was my web ...
0
votes
1answer
110 views

pset6 hello, python3: can't open file 'hello.py': [Errno 2] No such file or directory

I just started working on pset6 using python for the first time. However, it keeps telling me no such file. Am I supposed to install python3 myself into IDE or what is wrong?
0
votes
1answer
85 views

Final Project TypeError: execute() got multiple values for argument

I have been working on my final project, which is a chat application. I am, however, facing a problem when it comes to sending the messages. I am implementing my project through an SQL database for ...
0
votes
1answer
32 views

The ide returns an error saying “ilist index out of range” pointing to the initialisation of int k

if (len(sys.argv) != 2): print("please enter a key") """understand the key""" k = sys.argv[1] """prompt for input text""" message = cs50.get_string("plaintext:") """get ready to produce ...
0
votes
1answer
100 views

intersection of a list of arrays, python

I have two arrays that have dictionaries within them (these dictionaries objects in both arrays contain identical keys): a = [{1:"a", 2:"b"},{1:"c", 2:"d"}] b = [{1:"e", 2:"f"},{1:"c", 2:"d"}] I ...
1
vote
1answer
168 views

SPEED: python vs C crack program

I have implemented a python and c version of crack way back from problem set 2. Both of them work, and both use the same algorithms/processing just expressed in two different languages. Out of ...
0
votes
1answer
62 views

pset7 check50 fails to load external python module pandas

I'm getting the following error from check50: :| application starts up check50 ran into an error while running checks! Log No module named 'pandas' ... File "application.py", line 3, in <...
0
votes
0answers
154 views

Crack - recursive (Python)

For the brute force password cracking method I have used this iterative approach. I tried to write a recursive function that did the same, but I am struggling. Could anyone give some pointers on ...
0
votes
1answer
252 views

Pset 7 - Finance: Clicking Register creates: AttributeError: 'ValueError'

I've been trying to get my register page to work for a couple days now. I think I'm close , but now I'm receiving the following error message in my terminal when I try to click register from the login ...
0
votes
1answer
181 views

Pset7 - Finance (register function) - creating internal server error

I've been trying to figure out the register function for some time now, but I just can't get it to work. I'm also receiving an invalid syntax error for the last line of the function: return redirect(...
0
votes
1answer
132 views

I have problems applying Credit in python

I try to translate my code from c to python. I review the code several times and I think that is equal, but the program don't works despite in c works prefectly. This is my implementation: """Know ...
0
votes
1answer
124 views

jsonify not working when I add this line of code <<db = SQL(“sqlite:///mashup.db”)>> to application.py

I am trying to return a JSON on a certain URL in python application. Without this line db = SQL("sqlite:///mashup.db") everything works. The JSON is returned correctly. If I uncomment that line, ...
1
vote
1answer
81 views

pset6 mario/more fails one check50 test despite getting correct output

My code passes all tests of check50 running check50 cs50/2018/x/sentimental/mario/more except this one: rejects a height of 24, and then accepts a height of 2 expected " # #\n## ##\n", not "" ...
0
votes
1answer
95 views

pset6 credit.py returns INVALID for correct card number

When I input a valid credit card number, my code returns INVALID. I'm not sure about where did I go wrong in my code despite analysing it for hours. I would appreciate any help with this. Thank you :) ...
0
votes
1answer
227 views

PSET6 Similarities (More) 500 Internal Server Error

While performing testing of my web application, upon submitting the form and going to /score, none of the actual webpage is displayed, only the text: Internal Server Error The server encountered an ...
0
votes
1answer
38 views

What is if __name__ == “__main__”: doing in compare pset6?

I read the documentation, but I still can't pinpoint exactly what it is this line of code is doing in compare. The code of compare is as follows: #!/usr/bin/env python3 import argparse import re ...