Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
check this converting week number (int) into week day name (string) [solved]
## thats a lame way to do it ## forget doing this, check below how its done # #def dayNameFromWeekday(weekday): # if weekday == 0: # return "Monday" # if weekday == 1: # return "Tuesday" # if weekday == 2: # return "Wednesday" # if weekday == 3: # return "Thursday" # if weekday == 4: # return "Friday" # if weekday == 5: # return "Saturday" # if weekday == 6: # return "Sunday" # else: # print('error') ## make array of all the days in order ## zeroth element is monday, sixth element is sunday days=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"] ## accepts an integer, no strings, if weekday is more than 6 - prints error and returns something else than a week day def dayNameFromWeekday(weekday): if weekday>6: print('error'); return 'an unknown day' return days[weekday] ## get keyboard input but convert it to int nb = int(input('Enter weekday number [0 - 6]: ')) print('\n') ## print the result of the function print('today is: ' + dayNameFromWeekday(nb))
run
|
edit
|
history
|
help
0
L4-HW4-Finall
Linked Lists in python
Prime Numbers : -> Conventional Method
gj
My webapp demo
Rectangle Perimiter
course 2 steve sch
PyDataDescript
Python3: Class I : Person (Simple)
15