Scientific Computing with Python - Time Calculator. It works, but is this method correct?

I’ve just finished the Time Calculator project. It works fine, but it just seems so cumbersome. Because you can’t import modules (including the date time module), when it came to testing which day of the week had been entered (the optional argument) and which should therefore be displayed, I tested each string (translated to lowercase) 7 times, one for each day, then for each 7 times, I had to add 7 more if statements to change the output depending on which day of the week it may land on since I can’t just loop through and add days - that would require the date time module. It works fine, but it seems too verbose. Just wondering: should I be looking for a quicker way to do this, or is this the best that can be done without the date time module?

OK, and I’m getting an error in Replit, not from my code, but from the code that Freecodecamp supplied and says not to touch. Anyone else had that happen? It’s objecting to the unittest file.

please provide a link to your project, it’s impossible to know what’s going on without seeing the code

if you put the week days in a list, you can simply check at which index the day is, and add x days to it

That’s a good idea.
As for the errors, which you mentioned in my other post, it won’t let me copy and paste and the error list goes on for some time. I’ll type out one:
File “/nix/store/2vm88xw…-python3-3.18.12/lib/python3.8/unittest/”, line 60, in
and down the bottom of a bunch of these, it says "Import Error: "/nix/store… undefined symbol: __libc_siglongjmp, version GLIBC_PRIVATE.

Here is the link to the code with the errors. I haven’t used Replit before, so I’m not sure if just posting a link works. Let me know if you can’t access this:

I saw this suggestion recently, maybe it works for you too

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.