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

AttributeError: 'FeatureChartParser' object has no attribute 'nbest_parse'
How to get type of the file from the Google Cloud Storage based on its blobkey?
Custom collections in SQL Alchemy
SqlAlchemy + MySql 1205, 'Lock wait timeout exceeded; try restarting transaction'
Getting the float numbers from this string (Python)
Django function calls
How do I limit the amount of values in a list - Python 3
While loops and duplicate code in python
egg package import error in python project deploy
Having trouble installing the Quartz python module
How to specify list size using FactoryBoy
Redirect a part of traffic to other server
How to use a Chat script on a LAN?
Is any way to set success_url from urlconf parameter?
Reshaping numpy array without using two for loops
Match second number that follows a given pattern

Categories

HOME
crystal-reports
cil
answer-set-programming
vb6
nuxeo
cpu-architecture
laravel-5.2
concourse
console
subquery
openwrt
iso
nixos
store
ssms-2016
dendrogram
tweets
prediction
epicor
iup
tflearn
pdfsharp
excel-2013
dd-wrt
dhtmlx-scheduler
hibernate-cache
protobuf-net
clockwork
smart-mobile-studio
mmdrawercontroller
codesys
code-behind
concrete5-5.7
nsexception
tango
mod-fcgid
matlab-cvst
mouseclick-event
rhel6
instruction-set
nuget-server
paas
jszip
typhoon
easing
visible
kendo-combobox
spatial-query
twgl.js
handlebars.java
sonarqube5.3
self-hosting
programming-paradigms
wif
viper-architecture
ubercart
rspec3
musl
consensus
genetic-programming
power-law
boost-test
neoload
cling
nscolor
va-list
html-form-post
fluidsynth
arbor.js
transitive-closure-table
code-conversion
javascriptserializer
icefaces-3
plone-funnelweb
caliper
expression-evaluation
mysql-error-1045
path-manipulation
fileutils
nagle
act
economics
data-entry
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