Questions tagged [python]

Code using the python language.

Filter by
Sorted by
Tagged with
0 votes
1 answer
66 views

CS50P PSET3 outdated.py

I can't seem to get passed PSET3 outdated.py. I get two errors when running the check50 command: :( input of " 9/8/1636 " outputs 1636-09-08 expected "1636-09-08", not "1636 -...
user avatar
0 votes
1 answer
10 views

When I type python ~~.py, the output on the terminal is just "Python", not the ones that I wanted it to be printed out

Just like you could see in the picture, it appears to work just fine when I run the file by clicking the button above. But if I type python hello.py, the the outcome on the terminal is just "...
user avatar
0 votes
1 answer
53 views

PS6 Lines Of Code :( lines.py yields 2058 given 2058 lines of code in an open-source library file

I was wondering how to solve the last check on Lines of Code. Expected Output: 2058 Actual Output: Too few command-line arguments I recreated the file 2058.py with 2058 lines of code, and it worked. ...
user avatar
0 votes
0 answers
6 views

CS50 Web Project 4 network : How to join three tables with django orm

I'm working on CS50Web Project4 Network, and stuck at implementing Following page. I'd like to combine User, Post, Follower tables together to extract posts written by writers whom current user ...
user avatar
0 votes
0 answers
55 views

(CS50P PSET4) Little Professor accepts valid level is :( expected exit code 0, not 1

I'm having a hard time understanding what it means by this. It logs: running python3 testing.py get_level... sending input 1... checking that program exited with status 0... Everything else above &...
user avatar
0 votes
0 answers
19 views

CS50P - Week 8 - Object Oriented Programming - Problem faced with try-except block

I am currently on Week 8 Object Oriented Programming of CS50P This is with regards to an example given during the lecture at about 1:58:40, where we are suppose to use Try-Except to handle the ...
user avatar
0 votes
1 answer
214 views

I hope CS50 community can help why I got expected exit code 0, not 1

If I "return None" explicitly for exceptions in a regular .py file, when I do the test.py file, is it correct to test with a "assert function(argument) is None?" I did a pytest and ...
user avatar
  • 1
0 votes
1 answer
71 views

CS50P project6 shirt.py

question.. on CS50P project 6: shirt.py, I got an error message. I believe my error is on resizing the Moppest image but I don't know what else to do. I did what the instructions said but still having ...
user avatar
0 votes
1 answer
186 views

PS5 - Back to the Bank - check50 - expected exit code 0, not 1

For PS5 - Back to the Bank, the unit test script works when I run it on code50, however, when I run the check50 I am getting expected exit code 0, not 1. If anyone has a suggestion, I would greatly ...
user avatar
0 votes
2 answers
219 views

Why does my CS50P PSET4 Professor implementation fail check50?

For CS50P's Week 4 problem set Professor, my code appears to work fine when I test it, but check50 disagrees: :) professor.py exists :) Little Professor rejects level of 0 :) Little Professor rejects ...
user avatar
0 votes
0 answers
43 views

pset6 DNA problem with sequence 18

I have solved all the cases but sequences 18.txt always gives me "Harry" result but needs to have "No Match" result! I tried to debug but always the same results. Here is my code: ...
user avatar
0 votes
2 answers
150 views

:( Little Professor generates 10 problems before exiting

hi i am solving this question >> https://cs50.harvard.edu/python/2022/psets/4/professor/ my code is 100% correct. i have tested it several times but check50 is not able to pass all the tests. ...
user avatar
0 votes
1 answer
27 views

PSET9 FINANCE SQLITE "no such column exists" while multiplying two columns to update a third

In the Index function on APP.PY of my finance code, I'm getting "RuntimeError: no such column: total_per_share" even though I'm using "AS" to create this column -- please advise. @...
user avatar
0 votes
0 answers
30 views

Why do I get the error "expected string or buffer"?

The error occurs when I include the last line "tweets = [''.join(casual_tokenize(tweet, strip_handles = True, preserve_case = False)) for tweet in tweets]", in an attempt to tokenize. import ...
user avatar
  • 1
0 votes
0 answers
20 views

Finding a list of integers in a list of dictionaries containing strings

I am working on Pset6. I have distilled the matching Short Tandem Repeats found in the DNAsequence down to a list of integers stored in a list variable. What I want to do is locate the presence of ...
user avatar
0 votes
1 answer
28 views

my cs50 finance buy do not update in in the portfolio

i have tried so many options but to no avail pls below are the code i wrote.`@app.route("/buy", methods=["GET", "POST"]) @login_required def buy(): """Buy ...
user avatar
  • 15
0 votes
1 answer
120 views

Lab 9: Birthdays - odd behaviour from delete button

I got Lab 9 up and running per spec and am trying to implement a 'delete' button for each row. My current code works fine to delete each row in the table except for the first row (id = 1). When I ...
user avatar
0 votes
1 answer
39 views

Flask/Python PSET9 Finance -- Using PRINT() to debug

Having some problems with INDEX that I figure printing variable content to console will help me solve. BUT no matter what I try, print(variable) doesn't result in anything at all on the console/...
user avatar
0 votes
0 answers
23 views

Problem with cs50 python module

what does this error mean? c = 2147483622 Traceback (most recent call last): File "/home/ubuntu/pset6/mario.py", line 1, in <module> from cs50 import get_int File "/usr/...
user avatar
  • 1
0 votes
0 answers
16 views

My CS50 Web Project 1 Edit page is not updating entries

My edit function is shown below: def edit(request,entry): if request.method =="GET": text = util.get_entry(entry) return render(request, "encyclopedia/edit.html", { ...
user avatar
  • 1
0 votes
1 answer
21 views

Why doesn't my program run? cs50 psets6 DNA

When i only wrote the first few lines of my code everything worked fine. If i ran the code and i made an error in the command line argument, then i got a message in the terminal (just like it should ...
user avatar
  • 1
0 votes
1 answer
81 views

Lab9 -- Buttons to delete DB entries don't work

Can anyone please tell me why my "Remove Entry" from DB buttons don't work? I included the python.app code below the HTML: <!DOCTYPE html> <html lang="en"> ...
user avatar
0 votes
0 answers
20 views

PSET9 Finance - Check50 Failing on login - logging in as registered user succceeds -NameError: name 'get_symbol'

@app.route("/") @login_required def index(): """Show portfolio of stocks""" print("before") # Store the user_id. user_id = session["user_id"]...
user avatar
0 votes
0 answers
16 views

cs50 Finance Invalid Syntax on function declaration

When working on Finance I encountered a syntax problem which higlights a function declaration def buy(): ^ SyntaxError: invalid syntax. I have a feeling that because such an obvious thing was ...
user avatar
0 votes
0 answers
43 views

CS50 Web: How to redirect after creating a new entry?

I am stuck at wiki, problem 1 of the CS50 Web. I can't figure out how i should redirect the user after registering his new entry. I am trying to redirect to another page but it remains on the same &...
user avatar
0 votes
1 answer
69 views

PSET6 DNA Why is my (count consecutive substrings in string) function always returns 0's?

I tried writing different function variations but my count_dna function keeps returning zeroes (despite having consecutive sequences of STRs in the dna sequences)--can anyone please tell me why? Note: ...
user avatar
0 votes
2 answers
44 views

PSET6 Readability "unsupported operand type(s) for *: 'float' and 'NoneType'"

I'm getting "unsupported operand type(s) for *: 'float' and 'NoneType'" error for line 34: "s = (100 / words) * sentences". Not sure what to make of this since count_sentences(text)...
user avatar
0 votes
2 answers
30 views

Is there a way in jinja to display a block in a specific page?

I have a layout.html page with a <footer> that I want to display in almost all pages using {% extends "layout.html %}. Only in the user profile page the footer will be different. How can I ...
user avatar
0 votes
1 answer
40 views

Why am I getting FileNotFoundError when using os.listdir with a local pathway?

I have a folder "uploads" nested in "img" nested in my "static" folder. I am using the path "/static/img/uploads" to get a list of the files in the uploads ...
user avatar
  • 14
0 votes
1 answer
643 views

How to iterate over a list of values in a dict using jinja?

I have a dict with a list of values, basically each key has 10 values: movies = { 'title': ['The Shawshank Redemption', 'The Godfather', ..., 'The Lord of the Rings: The Fellowship of the Ring'], '...
user avatar
0 votes
0 answers
42 views

CS50 web network project: like button reloads page and only displays json data instead of the actual webpage

I am working on the cs50 web project network. When the like button is clicked the text in the button should then change to say unlike and the like count should increase by one without reloading the ...
user avatar
0 votes
0 answers
22 views

CS50 Web Wiki Edit Form. Form is returning empty in the edit function

I am having issues with an empty form being provided in the edit function. Everything works well but when I try to edit an entry I get a Value Error saying the HTTPResponse is None and that the ...
user avatar
0 votes
1 answer
24 views

Is there a way in python to limit an API result?

I'm making a Web Application about movies and using IMDb's API. Here's the JSON result: {"items":[{ "id":"tt0111161", "rank":"1", "title":&...
user avatar
0 votes
1 answer
267 views

Flask Filter Search/List in Python

I created a country list on the python search page section, the data is sent to the Html table with jinja syntax “ The Html table also has a JavaScript function it functions correctly no help with ...
user avatar
  • 37
0 votes
0 answers
5 views

cs50 list.py creat_engine() error

I am using sql server 2019, what should be the create_engine() should be? print(os.getenv("DATABASE_URL")) returns None following works: server = 'SHAH4563' database = 'PythonCS50' conn = ...
user avatar
0 votes
0 answers
38 views

Transitioning from CS50 IDE to VS Code

I recently finished with PSET9 and wanted to transition from CS50 IDE to VS Code for the Final Project. Problem is I don't know what exactly I need to setup to make it all work. I guessed that I just ...
user avatar
  • 1
0 votes
1 answer
144 views

My code gives error RuntimeError: no such table: File_Name

This is simplified version of my code from cs50 import SQL open("File_Name", "w").close() db = SQL("sqlite:///File_Name") id = 2 filename="hola" db.execute(&...
user avatar
0 votes
1 answer
40 views

Pset6 DNA. How to use a list in re.findall?

In pset6 DNA I'm using re.findall to find the nucleotides sequences but I'm only hardcoding the keys like this: re.findall(r'(?:TATC)+', sequence) So it's not working in the "large" database ...
user avatar
0 votes
0 answers
28 views

In Lab0 - Tic-Tac-Toe, calling the result function causes the error "local variable 'result' referenced before assignment"

I have the following code in the tictactoe module: def result(board, action): nextPlayer = player(board) board[action[0]][action[1]]=nextPlayer return board This works fine when called ...
user avatar
1 vote
1 answer
92 views

How should rounding be handled in pset6 readability?

I'm struggling to understand what sort of rounding needs to be implemented to produce the grade in [pset6 readability][1]. For the Harry Potter extract provided ("Harry Potter was a highly ...
user avatar
0 votes
1 answer
60 views

My program is not working

I am working on pset6 Mario. When I am running my program it is showing me some errors. But I think my code is correct. Here is my code: from cs50 import get_int row = 0 space = 0 insert = 0 ...
user avatar
0 votes
0 answers
247 views

Pset 9 finance-Problems for type= number output on the webpage

I am working on a CS50 task called "finance". The problem is that I get an error when I want to check the integer value of the share amount and put it on a separate template for checking my ...
user avatar
0 votes
1 answer
28 views

PSET 6 Credit More: always gives an output of INVALID

from cs50 import get_int, get_string import sys Prompt credit number input cardnumber = get_int("Number : ") #copying the credit card numbers into other variable / arrays cardnumber ...
user avatar
  • 1
0 votes
1 answer
27 views

help with python loops

I am trying to make a program for myself, not really related to any particular problem set. The issue I am having is that I want a loop to iterate over a block of code and force the user to give one ...
user avatar
0 votes
1 answer
97 views

Week 9 - I need a help about UNIQUE constraint

I am solving the week 9 problem using python. And I am interested in knowing how to deal with the error below using the if and elif? For example: rows = db.execute("SELECT username FROM users ...
user avatar
0 votes
1 answer
14 views

running the program in the background continuously even though I have to close the chrome page, how do I keep it running?

how to run a program in the background, I created an email sender that runs continuously the program I designed to check my server and if my server crashes the email sender will send an email to me. ...
user avatar
0 votes
1 answer
81 views

Credit Card Check

So I am on pset6 trying to implement the credit card check. I've already completed working through the numbers and am not having any issue with the actual algorithm. But for some reason my if ...
user avatar
0 votes
1 answer
480 views

CS50 Lab6 taking too long to run when trying to run the code

For Lab6 the code I have written seems to have problems running. Even with check50 it tells me that "check50 is taking longer than usual". I am unable to figure out what is wrong with my ...
user avatar
  • 5
0 votes
1 answer
95 views

How to get a specific date from a json file in Python?

So I have to get data from 2021 from this website which I am able to but I am unable to get the data from 2021. The following is the code I wrote that gets the dates: for d in data: ...
user avatar
0 votes
1 answer
82 views

pset6 DNA // having problem comparing elements from the database and the sequence file

Hi there I am having an issue comparing the data I have extracted from the sequence and the database files for now I am doing a sort of in efficient way but later I will fix it I am not sure really ...
user avatar
  • 17

1
2 3 4 5
7