Readme.md line3 SyntaxError: invalid syntax

Hi,

I get error when running my code ,

File “README.md”, line 3
This is the boilerplate for the Time Calculator project. Instructions for building your project can be found at hhttps://www.freecodecamp.org/learn/scientific-computing-with-python/scientific-computing-with-python-projects/time-calculator

SyntaxError: invalid syntax

Please provide a code snippet and/or a link to your repl.

Also, please wrap any code you do provide in triple backticks like so:

```languagenane
Your code here
```

Code in Python

“”"
days_of_week = [
‘Monday’
‘Tuesday’
‘Wednesday’
‘Thursday’
‘Friday’
‘Saturday’
‘Sunday’
]

def add_time(start, duration):

[L, meridiem] = start.split(" “)
[SH, SM] = L.split(”:“)
[DH, DM] = duration.split(”:")

total_minutes = int(SM) + int(DM)
total_hours = int(SH) + int(DH)
future_days = 0

if total_minutes >= 60:
total_minutes -= 60
total_hours += 1
if total_minutes < 10:
total_minutes = f"{total_minutes}".zfill(2)

if total_hours >= 12:
t, r = divmod(total_hours, 12)
total_hours = r if r else total_hours
if total_hours > 12:
total_hours = total_hours - ((t - 1) * 12)

if t > 0:
if meridiem == ‘PM’:
future_days = ((t - 1) // 2) + 1
else:
future_days = t // 2

if t > 0 and t % 2 != 0:
meridiem = ‘AM’ if meridiem == ‘PM’ else ‘PM’

new_time = str(total_hours) + “:”
new_time = str(total_minutes) + f"{meridiem}"

if args:
day = args[0].title()
if future_days > 0:
index = days_of_week.index(day)
index += future_days % 7

  if index > 6:
    index = index - 7
  day = days_of_week(index)

new_time += f",, {day}"

if future_days == 1:
new_time += " (next day)"
elif future_days > 1:
new_time += f" ({future_days} days later)".rjust(11)

return new_time
“”"

Please use ``` instead of """ when trying to wrap your code so it gets properly formatted.

Also, please Show Hidden Files and provide the content of your .replit file.

.replit folder
‘’’

The primary language of the repl. There can be others, though!

language = “python3”
entrypoint = “README.md”

A list of globs that specify which files and directories should

be hidden in the workspace.

hidden = [“venv”, “.config”, “/pycache", "/.mypy_cache”, “**/*.pyc”]

Specifies which nix channel to use when building the environment.

[nix]
channel = “stable-22_11”

The command to start the interpreter.

[interpreter]
[interpreter.command]
args = [
“stderred”,
“–”,
“prybar-python310”,
“-q”,
“–ps1”,
"\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ",
“-i”,
]
env = { LD_LIBRARY_PATH = “$PYTHON_LD_LIBRARY_PATH” }

[env]
VIRTUAL_ENV = “/home/runner/${REPL_SLUG}/venv”
PATH = “${VIRTUAL_ENV}/bin”
PYTHONPATH = “$PYTHONHOME/lib/python3.10:${VIRTUAL_ENV}/lib/python3.10/site-packages”
REPLIT_POETRY_PYPI_REPOSITORY = “https://package-proxy.replit.com/pypi/
MPLBACKEND = “TkAgg”
POETRY_CACHE_DIR = “${HOME}/${REPL_SLUG}/.cache/pypoetry”

Enable unit tests. This is only supported for a few languages.

[unitTest]
language = “python3”

Add a debugger!

[debugger]
support = true

How to start the debugger.

[debugger.interactive]
transport = “localhost:0”
startCommand = [“dap-python”, “main.py”]

# How to communicate with the debugger.
[debugger.interactive.integratedAdapter]
dapTcpAddress = "localhost:0"

# How to tell the debugger to start a debugging session.
[debugger.interactive.initializeMessage]
command = "initialize"
type = "request"

  [debugger.interactive.initializeMessage.arguments]
  adapterID = "debugpy"
  clientID = "replit"
  clientName = "replit.com"
  columnsStartAt1 = true
  linesStartAt1 = true
  locale = "en-us"
  pathFormat = "path"
  supportsInvalidatedEvent = true
  supportsProgressReporting = true
  supportsRunInTerminalRequest = true
  supportsVariablePaging = true
  supportsVariableType = true

# How to tell the debugger to start the debuggee application.
[debugger.interactive.launchMessage]
command = "attach"
type = "request"

  [debugger.interactive.launchMessage.arguments]
  logging = {}

Configures the packager.

[packager]
language = “python3”
ignoredPackages = [“unit_tests”]

[packager.features]
enabledForHosting = false

Enable searching packages from the sidebar.

packageSearch = true

Enable guessing what packages are needed from the code.

guessImports = true

These are the files that need to be preserved when this

language template is used as the base language template

for Python repos imported from GitHub

[gitHubImport]
requiredFiles = [“.replit”, “replit.nix”, “.config”, “venv”]

[languages]

[languages.python3]
pattern = “**/*.py”

[languages.python3.languageServer]
start = “pylsp”

[deployment]
run = [“sh”, “-c”, “python3 main.py”]
‘’’

replit.nix folder
‘’’
{ pkgs }: {
deps = [
pkgs.python310Full
pkgs.replitPackages.prybar-python310
pkgs.replitPackages.stderred
];
env = {
PYTHON_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
# Needed for pandas / numpy
pkgs.stdenv.cc.cc.lib
pkgs.zlib
# Needed for pygame
pkgs.glib
# Needed for matplotlib
pkgs.xorg.libX11
];
PYTHONHOME = “${pkgs.python310Full}”;
PYTHONBIN = “${pkgs.python310Full}/bin/python3.10”;
LANG = “en_US.UTF-8”;
STDERREDBIN = “${pkgs.replitPackages.stderred}/bin/stderred”;
PRYBAR_PYTHON_BIN = “${pkgs.replitPackages.prybar-python310}/bin/prybar-python310”;
};
}
‘’’

Those are still the wrong things to wrap your code in, but oh well.

Your issue is that the code’s entrypoint is set to README.md. Change entrypoint = "README.md" to entrypoint = "main.py".

1 Like

Thanks for the help, but unfortunately it doesn’t work.
Maybe you have some other suggestions?

Yes the stuff to format your code is three backticks ``` and you are using quotes and apostrophes. On an american keyboard, the backticks are located directly above the tab button. You could just copy and paste too.

1 Like

It appears that there is a bug in your program. Can we have the link to the Repl?

1 Like

Thanks for the help!

1 Like

Will you see this way?

https://replit.com/@RenarsR1/boilerplate-time-calculator#time_calculator.py

1 Like

Yes that will work just fine. I will look at the code.

1 Like

It appears that you never defined args in time_calculator.py. What is it supposed to do? You already have the variables start and duration in the function add_time due to them being parameters. You never created any args. IIRC you would use def add_time(start, duration, *other) and then other would be your list of args.

1 Like