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

Summing values of a pandas data frame given a list of columns [duplicate]
Why is the top level package being removed? Python
List of objects function not working
multiple assignments in one line for loop python
selenium unicode encode error
Why npycharm telling me format is not an attribute of string
What is the MATLAB equivalent of a named tuple in Python?
Differences of scipy.spatial.KDTree in python 2.7 and 3.5
Getting correct exogenous least squares prediction in Python statsmodels
How can I merge two beautiful soup tags?
Python String Query
How to create and use multiple pipes within the same process with pexpect?
Python Error 24: too many files open: Per Process Limit?
How to plot a Gaussian function on Python?
Running a script for many files of the same extension. Getting 'UnboundLocalError'
Connecting to IBM AS400 server for database operations hangs

Categories

HOME
json
xamarin.android
facebook-graph-api
label
parse-server
couchdb-2.0
orientation
urlencode
subquery
desktop
android-viewpager
gatsby
ida
scala-native
netezza
ssms-2016
bar-chart
flexlm
attask
excel-2010
scalaz7
jquery-form-validator
k2
explode
http-method
badge
tampermonkey
compare-and-swap
pep8-assembly
twitter-bootstrap-2
postgresql-9.2
ipfw
swiftcharts
large-data
superpowered
rider
autocompletetextview
wcf-security
stdclass
stereo-3d
crop
pytest-django
tableau-server
nsjsonserialization
seamless-immutable
xmgrace
spring-data-hadoop
decompress
chrome-remote-desktop
struts-layout
jszip
laravel-query-builder
sql-server-administration
windows-azure-pack
debugdiag
activeweb
software-product-lines
git-annex
firepath
pax-web
django-filer
brython
dbscan
flexjson
sun-codemodel
difference
insertion-sort
schtasks.exe
enyo
wikitext
code-readability
unity5.3
datasnap
retro-computing
visual-studio-code
webhdfs
digits
pgm
xaml-designer
hg-git
sysfs
pisa
inputaccessoryview
viewflipper
utf-32
alphablending
temp-tables
qtestlib
formvalidation-plugin
ogr2ogr
ghostdoc
genetic-programming
mfmailcomposeviewcontroll
ifft
initialization-vector
operations
dynamics-ax-2009
magickwand
wpdb
tridion2009
mvs
radchart
getstring
hibernate3
driving-directions
scraperwiki
galaxy-tab
cookieless
associative
server-error
search-path
squeel
winverifytrust
filetime
web-statistics
act
standardized
self-reference
divx

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