Questions tagged [python]

Code using the python language.

Filter by
Sorted by
Tagged with
0
votes
0answers
12 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/...
0
votes
0answers
4 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", { ...
0
votes
1answer
16 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 ...
0
votes
1answer
26 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"> ...
0
votes
0answers
12 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"]...
0
votes
0answers
12 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 ...
0
votes
0answers
13 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 &...
0
votes
1answer
47 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: ...
0
votes
2answers
28 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)...
0
votes
2answers
19 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 ...
0
votes
1answer
20 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 ...
0
votes
1answer
113 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'], '...
0
votes
0answers
23 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 ...
0
votes
0answers
19 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 ...
0
votes
1answer
21 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":&...
0
votes
1answer
74 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 ...
0
votes
0answers
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 = ...
0
votes
0answers
16 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 ...
0
votes
1answer
32 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(&...
0
votes
1answer
34 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 ...
0
votes
0answers
24 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 ...
1
vote
1answer
65 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 ...
0
votes
1answer
47 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 ...
0
votes
0answers
234 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 ...
0
votes
0answers
19 views

Pset6 Readability Python: no output

from cs50 import get_string, get_int import sys def main(): statement = get_string("Text: ") count = len(statement) no_words = count_words(statement) no_letters = ...
0
votes
1answer
21 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 ...
0
votes
0answers
5 views

I don't know how this is an error. It is from the api of iqoption. https://iqoptionapi.github.io/

I don't know how this is an error. It is from the api of iqoption https://iqoptionapi.github.io/
0
votes
0answers
27 views

Week 9 - Finance. How could I check de return?

I am coding the week 9 problem (Finance) and I am part of (quote) and I have some doubts. The lookup () function returns (none) if the API does not find (stock). I am interested in how I check using ...
0
votes
0answers
14 views

Problem with pset6 readability.py

It showing that one test failing. expected "Grade 8\n", not "Grade 7\n" After I'm going to results page, copy the text they use in test and manually testing it in my console, The ...
0
votes
1answer
26 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 ...
0
votes
1answer
65 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 ...
0
votes
1answer
12 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. ...
0
votes
1answer
69 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 ...
0
votes
0answers
11 views

Server problem exit?

I run the python scraper bot but after a while the problem appears = --- server exit problem ---- how to handle it?
0
votes
1answer
384 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 ...
0
votes
1answer
35 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: ...
0
votes
0answers
26 views

Request throwing JSON error

I'm having a very strange problem. This code, which was working perfectly yesterday, is now throwing the error - File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode ...
0
votes
1answer
74 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 ...
0
votes
1answer
750 views

Calling a javascript function from flask

For my final project, I am creating a flask web mapping application, which with user input displays different things on a map. At the moment, when they input a place name via a form, my python ...
0
votes
1answer
42 views

Imprecision during float subtraction in python

During pset6/cash, I tried to write the python code without multiplying change by 100 to get cents (as I had in c). I had assumed that this wouldn't lead to any precision issues, however when ...
0
votes
2answers
503 views

Mail CS50 Web - How to Send Email (API not working)

I'm very new to Javascript and working on mail, project 3 for CS50 web. I've been working on just sending the email initially, for about a week and I'm getting very discouraged. I can't seem to get ...
0
votes
0answers
153 views

What's wrong with my register function? (Pset9 - Finance)

Here's my register function in application.py: @app.route("/register", methods=["GET", "POST"]) def register(): """Register user""" ...
0
votes
2answers
44 views

mario more (python)

I've tried to make my code efficient by reducing the number of loops/print functions compared with my solution in c. My code works, but check50 isn't happy with it -- apparently an extra space is ...
0
votes
1answer
28 views

get_string function not working on pset6 2020

here is the problem ~/ $ python hello.py Traceback (most recent call last): File "/home/ubuntu/hello.py", line 1, in <module> answer = Get_string("what is your name") ...
0
votes
1answer
28 views

IDE.CS50.io can't get FireFox to full screen. Tried the F10 and F11

I'm trying to get Firefox to display IDE.CS50.IO in to full screen mode, which I thought was F10 or F11 and neither works. Thank you kindly, John
0
votes
1answer
68 views

Mario (less) PSET6 Python Spacing help

Slightly embarrassed to be posting this as I could succesfully complete mario(less) in pset1 but apparently cannot replicate it in Python. My code is as follows: h = int(input("h: ")) # get ...
0
votes
1answer
63 views

pset6 credit help with calculations in python

I am trying to convert my credit solution from C to python, but for some reason it is not working. Attached is my code and the problems from cs50 import get_int card, a, m, v = False, False, False, ...
0
votes
1answer
244 views

Generate dynamic datefields from selected dropdown value sent to another route in Flask

EDIT With the good help of @DinoCoderSaurus, I realised that I overlooked adding a POST method to the datainput form and the routes also lacked GET and POST methods. Adding those modifications helped ...
0
votes
1answer
69 views

Pset6 Cs50 = Readability false output

I have been trying to complete readability python but on every result it is showing before Grade one from cs50 import get_string s = get_string("Text: ").strip() num_letters, num_sentences,...
0
votes
1answer
49 views

PSET6 - Readability: false grade output

from cs50 import get_string text = get_string("Text: ") letters = sentences = i = words = 0 length = len(text) while i < length: if text[i].isalpha(): letters += 1 //...

1
2 3 4 5 6