Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Add this tag to your question to indicate that you are new to the language of your code. This will often be taken into consideration by reviewers when assessing your code.
2
votes
Advent of Code 2022 - Day 3
Type hints
Use type hints to clearly display what types are accepted by a function, and what types are returned. Disclaimer: These type hits are written using Python 3.11, so you might need to update …
2
votes
1
answer
175
views
Employee lookup with hard-coded database entries
I'm creating a DataBase for looking up employee's different stats in a company.
Is there any way I can make this more compact/efficient?
/**
* Write a description of class DataBase here.
*
* @au …
4
votes
3
answers
359
views
Swimming Pool Staff/Patron Structure
To work on my Java skills, I decided to create a structure for a pool that I work at. Lifeguards get shifted when their time at their position is up, and managers periodically check the pH level of th …
4
votes
Accepted
Login and Register program
Please indent your code
Taking a first pass it was really difficult to determine where functions ended. While I was scanning it looked like you have random while statements outside your functions. Ind …
3
votes
Accepted
Python - Password Generator & Strength Checker
Reliability
I get that this program is meant for you to continue learning python, but please don't use any passwords generated by this program. Especially since your strength check is really weak. I.E …
1
vote
Accepted
Rock Paper Scissors Beginner Python Game
Welcome to Python!
Choosing Rock/Paper/Scissors/
This
if choice == 'R':
choice = "Rock"
elif choice == 'P':
choice = "Paper"
elif choice == 'S':
choice = "Scissors"
can be
choice = …
7
votes
Accepted
Interactive Discord bot for tabletop RPG
List Comprehension
Instead of
roll = []
for x in range(0, dice):
roll.append(roll_die())
do this
roll = [roll_die() for _ in range(0, dice)]
The result is the same, it requires less code, …
1
vote
Constructing a lexicon and frequency array from a long string
Your for loop can be reduced to one line, utilizing sum:
frequency_train = [
sum(1 if lexicon_train[i] in email else 0 for email in X_train) for i in range(211441)
]
It removes the need to crea …
1
vote
Beginner Hangman Game
Getting lines from a file
You can use simple list comprehension to get all the lines from a file.
words = [word for word in open("dictionary.txt", "r")]
However, this does not ensure the file will …
0
votes
Accepted
Tic Tac Toe in Python 3
Displaying the grid
Personally, I would move displaying the grid into a separate function, such as display_grid:
def display_grid() -> None:
for row in game:
print(row)
This removes th …
3
votes
Accepted
text-based RPG game in python- character selection
Naming
I would make the following changes
w() -> remove
t() -> print_text()
Since w() is just time.sleep, it isn't necessary. And someone looking at your code would understand time.sleep a lot after …
3
votes
Accepted
Hangman Game from OCW MIT 6.0001 Pset No. 2
I'm going to go function by function and explain what I changed and why.
Imports I used:
from typing import List
load_words
def load_words() -> List[str]:
"""
Returns a list of valid words. …
1
vote
Simple blackjack game using OOP
Blackjack.hit_or_stand
This function can be shortened to the following
def hit_or_stand(self):
while decision := input("(hit/stand h/s): ").lower()[0]:
if decision in 'hs':
ret …
2
votes
Strong Password Detection in Python
You preform multiple function calls which are all very related. You can cram each of the regex checks into one if statement.
You should use a main guard to ensure that the code is only running if thi …
2
votes
Beginner user registration and login program
Not a full review, but too long for a comment
I'm not a C++ developer, but there are a few common foundational programming mistakes that you've made that I saw:
using namespace std is a bad practic …