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

Setting cookies for static files using bottle.py
Python/Feedparser: reading RSS feed fails
How to generate a Torrent Magnet URI from a directory?
Python/Kivy camera widget error with opencv
Python3 - When exactly do you need to prepend “self._” to variable declarations within class methods? [duplicate]
how to tell python 3 to skip over non-digit characters from a csv file
writing numpy codes in cython with unknown dimensions
How to refresh django connection when inserting in SQL
How to get this enum if I only have a string representation in Python 2.7
How to escape Unicode in Python 3
Performance of timezone-aware Pandas DateTimeIndex
How to remove single space between text
Writing out results with function in.txt document when there's min and max?
Not understanding why I cant use use cx_Oracle with Django
Convert a complex array of array to a list
sorted on basis of two keys, descending order sort for first and ascending for second

Categories

HOME
sass
filterrific
amazon-swf
antivirus
firebase-app-indexing
translation
wms
automated-tests
apache2
rfc
rocketmq
flyway
phonegap-cli
histogrammar
ext.net
simpy
spring-cloud-contract
avl-tree
currency
android-viewpager
lotus-notes
getorgchart
gatsby
cloudflare
dendrogram
bar-chart
google-api-java-client
thumbnails
scalaz7
nmf
auditing
pipelinedb
excel-2013
version-numbering
cgal
multichoiceitems
jackson-dataformat-csv
edb
mapguide
sidr
mmdrawercontroller
vmd
android-download-manager
linq-to-entities
android-preferences
powermta
pytest-django
stress-testing
catia
estimation
webdatagrid
mouseclick-event
shutdown
chrome-remote-desktop
info
bacnet
asteriskami
dojox.charting
project-online
sun-codemodel
interactive-brokers
bluesnap
loopj
file-diffs
application-loader
built-in
castle-windsor-3
gray-code
google-hadoop
custom-url
searchkick
word-2013
ejabberd-saas
gyroscope-framework
livechat
vcl
em
sid
bullet
map-force
flash-cc
bfd
cdata
nsmatrix
swrl
google-closure-library
shiva3d
tridion2009
linkedhashset
gdt
visual-web-gui
electronic-signature
msbuildextensionpack
smooth
ruby-debug
carbide
web-analytics-tools

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App