Skip to main content
10 votes

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

This has been discussed on the CS50 ED Discussion Forums. Have you reviewed them? The first check is running your tests against their test "correct version" of bank.py (not your version). So,...
kcw78's user avatar
  • 837
7 votes
Accepted

IndexError in initial state of pset6 Sentiments

This command pip3 install --user -r requirements.txt --upgrade solves the problem according to this post on reddit (and the comments here :).
DinoCoderSaurus's user avatar
7 votes

Instance of 'scoped_session' has no 'commit' member

They are warnings from pylint. You can tell pylint to ignore that error by create file .pylintrc in your folder with contains: ignored-classes=SQLObject,Registrant,scoped_session reference link: ...
Nikola's user avatar
  • 71
5 votes
Accepted

Pset8: typeahead not working in js fileā€»i am using python for solving this problem set

One common cause of this problem is search returning a nested list instead of a list. A quick way to detect this is doing a call to search?q=021. If the result shows nested lists: [ [ { "...
DinoCoderSaurus's user avatar
5 votes

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

Please have A look at my code, please upvote if helps,your code a kind of complicated. I tested with check50 as well, All Passed. fuel.py def main(): fraction = input("Fraction: ") ...
souttawther's user avatar
5 votes
Accepted

CS50P PSET3 outdated.py

The input " 9/8/1636 " contains the (trailing) space and the program does not account for that, therefore it is in the output as entered. "other than a missing comma." is a good ...
DinoCoderSaurus's user avatar
4 votes
Accepted

Why can't I use get_int in python

In python, if you want to use a function from an imported library, you have to somehow tell Python that you are going to get that function from which library. I would do: h= cs50.get_int() or ...
Ha Tran's user avatar
  • 74
4 votes
Accepted

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

So it seems the workaround solution was to add app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False somewhere after the app = Flask(__name__) The issue has been reported (https://github.com/pallets/...
Blauelf's user avatar
  • 21k
4 votes

Why does my CS50P PSET4 Professor implementation fail check50?

I had the same problem. Issue is in this line of code: return random.randint(10 ** (n - 1), 10**n - 1) the feedback from check50 is that you failed 'At Level 1, Little Professor generates addition ...
sarah zaccagni's user avatar
3 votes
Accepted

Python. Can't understand this code

The [expression_using_X for X in Y] is evaluating expression_using_X for every X being an element of Y, and the [] make that list of expression values a Python list. squares = [x**2 for x in range(11)...
Blauelf's user avatar
  • 21k
3 votes
Accepted

C vs Python in MOOCs?

You can find the "official" answer from David Malan himself here: "Why does CS50 at Harvard use C as its primary language?" A few words from my own perspective... I began my formal programming ...
Peter's user avatar
  • 1,410
3 votes
Accepted

python invalid syntax end=""

I added a space in there and it took the flag away. The rest of the print lines without the space are not flag. I'm wondering if this is a bug with the IDE or am I not understanding something? This ...
Adam's user avatar
  • 41
3 votes
Accepted

Pset7, Index: How to use loops in Python and Jinja?

The for loop is working and is displaying exactly the data it has. And it technically (theoretically?) is identical to a for loop in C. Perform this code x times. Syntactically, you (normally) tell C ...
DinoCoderSaurus's user avatar
3 votes
Accepted

How to fix KeyError: 'id' error in pset7 register?

True. row has no element id because row only contains the columns selected. But do you really need to do another SELECT? From the spec Hints: If str is an INSERT, and the table into which data was ...
DinoCoderSaurus's user avatar
3 votes
Accepted

Why can't I print the entire string from the read file?

I guess you meant print(dna[i:i+len("AGATC")]). In Python, if the end of the substring is before the beginning, the substring is empty, so you are printing a bunch of empty strings.
Blauelf's user avatar
  • 21k
3 votes

:( Little Professor generates 10 problems before exiting

i used randint instead of randrange to generate unique questions. dunno why it didnt work with randrange. if level == 1: num1 = random.randint(0, 9) num2 = random.randint(0, 9) ...
shiva kharbanda's user avatar
3 votes

CS50P PSET3 outdated.py

@DinoCoderSaurus is 100% correct. When you receive input, always make sure to strip() the input, unless specified that leading and trailing spaces are required. like this: date = input("Date: &...
Sifiso Lucolo Dhlamini's user avatar
3 votes

(Edited) CS50P - PSET 4 - LITTLE PROFESSOR

There is a requirement "hidden" in the How to Test section. Under the 3rd bullet it says (in part): Your program should output 10 distinct problems before printing... A review of your code ...
kcw78's user avatar
  • 837
3 votes
Accepted

iterate pagerank issue in cs50ai pagerank project

I think you are correctly calculating new pagerank values at iteration N+1 from values at iteration N. To confirm, here are the new page rank values you should get after the first iteration with ...
kcw78's user avatar
  • 837
3 votes

TypeError: 'NoneType' object is not subscriptable in PSET9, but working manually

I noticed that the issue lies in the line where I insert the stock symbol into the "stocks" table in the buy function. The problem is that I am passing stock["name"] instead of ...
Chris's user avatar
  • 31
2 votes
Accepted

For register in pset 7 where I am doing wrong?

It looks like this function will always print "Both passwords don't match" and redirect to register.html (unless username or password is blank). In pseudo-C this routine would look like: if (username ...
DinoCoderSaurus's user avatar
2 votes

Problem with cs50 python module - folder restricted

I had the same problem as you describe in your post. As @Rushil mentioned in his comment, it can be sorted by renaming the file you have named "string.py" in your directory. Seems there is a conflict ...
flymats's user avatar
  • 23
2 votes

C vs Python in MOOCs?

I've noticed that many universities (including MIT) seem to prefer Python as a starting language. That's true! I myself prefer Python as a starting language. However, I can understand why CS50 is ...
SuperNovaCoder's user avatar
2 votes
Accepted

Make the code better - analyzer.py pset6

positives and negatives are file names sent to the function, so instead of hardcoding the file name like this with open("negative-words.txt") as negative:, use the variable name like this with ...
DinoCoderSaurus's user avatar
2 votes
Accepted

Pset6 2017 - 'str' object has no attribute 'isaplha' - caesar.py

Check your spelling! Sometimes it's the simple things ;)
Steve Bunting's user avatar
2 votes

Caesar (python) error

I think the problem is that you have a () around the if(plaintext[i].isalpha): when it should be if plaintext[i].isaplha(), and the same for isupper and islower. I had the same problem but when I ...
see90's user avatar
  • 27
2 votes

Caesar (python) error

From the Hints section of the spec: You might find chr and/or ord of help. Python does not treat plaintext[i] the same way that C does. That's where ord comes in. Python int is more like atoi ...
DinoCoderSaurus's user avatar
2 votes
Accepted

How to use multiple "WHERE" while updating table in sqlite

You can use the AND logic keyword, as below: UPDATE table SET field1=value1 WHERE field2=value2 AND field3=value3 There is also an OR keyword.
Steve Bunting's user avatar
2 votes

Pset7 - Finance: Cannot figure out how to loop through values in list/dict in order to display results in rows in html table

What is going to be stored into your holdings value is "A list of dictionaries", where each list item will be one stock. i.e each list item will correspond to each row of your query: "SELECT stock, ...
Hydes's user avatar
  • 123
2 votes
Accepted

Pset7 buy - RuntimeError sqlite3.OperationalError near transaction

transaction is a sqlite reserved word. You'll need to escape the column name with quotes (eg 'transaction') or create the table again and rename the column.
DinoCoderSaurus's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible