python


Fundamentals of computer programming


I'm trying to create a program that will display the number of times a specific weekday for a given month and year occurs. It's supposed to process only one request per invocation and should be aware of the number of parameters present on the command line and should display an error if there are more than three fields present. I'm having trouble figuring what to do next but the format is suppose to be [ Weekday [Month] [Year] ].
This is my code so far:
def ParseText ( text, items, errormessage ):
matches = 0
for index in range( len(items) ):
curtext = items[index].casefold()
if curtex.startwith( text.casefold() ):
matches += 1
match = index
if matches != 1:
print ( "\"%s\" is not a valid %s" % ( text, errormessage ) )
exit ( 1 ) #invalid command line argument
return match
import sys
import dates
cmdline = sys.argv
if len( cmdline ) == 1:
print ( "Usage: calcount Weekday" )
exit ( 0 )
DaysText = ( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" )
MonthsText = ( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" )
dayofweek = ParseText ( cmdline[1], DaysText, "day of the week" )
print ( "You have requested", DayText[dayofweek] )
for i in range(30):
print ( "DOW for January %d, 2020 is %d" % ( i, dates.weekday( 1, i, 2020 ) ) )
I'm using python 3.6.1.


Related Links

Trying to do a natural join using python standard library
How to combine several querysets by key in common?
How I can speed up row column access to pandas dataframe?
Create list with combinations of 3 elements of other list with repetitions
PyQt5 does not change gifs
Pydub - combine split_on_silence with minimum length / file size
how to choose python version accordingly in pycharm?
Unable to import Flask to Kivy iOS
Unique list without spliting entries based on spaces in python
Uncaught SyntaxError: Unexpected token & error for flask and html
Django celery tasks working very long
Python, create plot from DataFrame
having this error TypeError: cannot concatenate 'str' and 'int' objects when trying to do math with variables stored with pickle
Pygame Tone Generator [duplicate]
Django - custom userprofile NoSuchTable error
How do you name a new instance of a class when you don't know what the name is in advance? [duplicate]

Categories

HOME
tensorflow
sass
textwatcher
reportportal
flyway
gspread
sequelize.js
onenote-api
metronic
cartodb
lstm
uisplitviewcontroller
mule-studio
atlassian-plugin-sdk
attask
jive
backpropagation
onsen-ui
spring-test
hanami
i3
dhtmlx-scheduler
roundcube
strophe
consumer
construct-2
rhomobile
transient
mmdrawercontroller
silverlight-3.0
delphi-10.1-berlin
equivalence
jquery-multidatespicker
brute-force
polyfills
lexical-analysis
intellilock
datalog
spring-bean
startapp
email-parsing
estimation
fqdn
modelattribute
heroku-postgres
photography
adler32
cron-task
webkit2
inotifypropertychanged
squirrel
picking
anti-cheat
cctray
persistence.xml
function-fitting
document-oriented-db
unity5.3
programming-paradigms
webhdfs
playscape
type-mismatch
pylearn
swift2.1
jazz
jcr-sql2
java-melody
utf-32
x-ua-compatible
dto
ember-addon
funkload
alertifyjs
indexing-service
slick-2.0
db4o
edit-in-place
operations
visual-c++-2010-express
ng-pattern
snapjs
pitch
getusermedia
shim
rose-db-object
z-machine
makefile-project
ou
scraperwiki
msbuildextensionpack
search-path
rijndael
carbide
recordset
hadoop-plugins
multibyte-functions
openwysiwyg
internals
associativity





Mobile Apps Dev
Database Users
javascript
java
csharp
php
android


MS Developer
developer works
python
ios
c
html
jquery


RDBMS discuss