Questions tagged [python]

Code using the python language.

Filter by
Sorted by
Tagged with
0
votes
1answer
25 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
20 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
17 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
18 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
11 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
9 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
19 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
25 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
23 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
54 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
39 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
146 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
18 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
20 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
23 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
41 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
11 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
62 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
9 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
239 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
27 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
24 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
71 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
570 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
32 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
392 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
126 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
37 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
22 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
23 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
60 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
0answers
86 views

pset6 dna question regarding searching string for substring, two types of code give different output

I am currently following along ayoutube tutorial for pset 6 DNA, and have a small question regarding a specific function. In this function, it basically takes a substring and a string, and counts the ...
0
votes
0answers
15 views

Same SQL query works in IDE but not in pythonanywhere?

In my web application I have an sqlitequery that works perfectly as desired in my IDE, but always raises an SErver Error 500 in my pythonanywhere hosting. It is the exact same code: else: # ...
0
votes
1answer
47 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
211 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
53 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
44 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 //...
0
votes
1answer
34 views

Pset 6 - Readability printing one grade off

I managed to translate readability from C to python, except it is printing one grade lower than what it is supposed to when testing. What am I missing here? """ 1) Ask user for phrase 2)...
0
votes
1answer
35 views

Can't update shopping cart for more than one item, works fine for a single item, otherwise only the first one gets updated

I am trying to update the quantity of the products in the shopping cart by changing the number in the dropdown. If the cart has two or more items then only the first one works and the qty doesn't ...
0
votes
0answers
52 views

CS50 PSET 6 DNA Just Returns First Name

I've been working on DNA for a while now and thought I was done, but there's a problem with my code. Everytime I run it, the program just prints the first name on the database, so either 'Albus' or '...
0
votes
1answer
51 views

Pset6 mario more didn't pass the test

I run through my code many times and didn't find anything wrong with it but the result printed out wasn't right: from cs50 import get_int while True: height = get_int("How high is the pyramid?...
0
votes
1answer
191 views

CS50W Project 4 / Network - like counter not always saving to database

I was able to implement a like counter where it keeps track of all the likes. For some reason though, it randomly doesn't save the counter to the database when I submit the PUT request. I can't figure ...
0
votes
0answers
76 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
1answer
27 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
1answer
105 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
1answer
15 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 ...

1
2 3 4 5 6