7 Replies - 270 Views - Last Post: 08 August 2014 - 07:10 AM Rate Topic: -----

#1 oldcrescent  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-August 14

Day of the week,tomorow is...code

Posted 07 August 2014 - 04:27 PM

Hi,im very stuck with one bit of code and its really annoying me.I'd like to be able to have a code where it asks you the day of the week and then can tell you what day tomorrow is. I'd like to be able to do it for seven days of the week. I did alot of research and could only find things on dates.
I'd really appreciate if someone could figure this out for me

Today is:wednesday
tomorow is:thursday
Is This A Good Question/Topic? 0
  • +

Replies To: Day of the week,tomorow is...code

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3514
  • View blog
  • Posts: 11,996
  • Joined: 12-December 12

Re: Day of the week,tomorow is...code

Posted 07 August 2014 - 04:28 PM

Quote

I'd really appreciate if someone could figure this out for me

What have you tried? Where is your code-attempt? We won't just provide you with code.

This post has been edited by andrewsw: 07 August 2014 - 04:29 PM

Was This Post Helpful? 0
  • +
  • -

#3 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7802
  • View blog
  • Posts: 13,197
  • Joined: 19-March 11

Re: Day of the week,tomorow is...code

Posted 07 August 2014 - 04:34 PM

There are a couple of ways to think about this problem. I can think of three solutions that should be in your grasp without even putting my mind to it. Show us what you've got, and we'll help you get the kinks out of it.
Was This Post Helpful? 0
  • +
  • -

#4 oldcrescent  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-August 14

Re: Day of the week,tomorow is...code

Posted 07 August 2014 - 11:45 PM

Please guys. I have an exam in two hours and it has just annoyed me. Could you give me a clue so i know where to start. Please, im really stuck
Was This Post Helpful? 0
  • +
  • -

#5 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7802
  • View blog
  • Posts: 13,197
  • Joined: 19-March 11

Re: Day of the week,tomorow is...code

Posted 07 August 2014 - 11:47 PM

You could do this with a list, or with a dict. Either of these is quite simple. Please, give it a try. The exam is intended to test your abilities, not mine.
Was This Post Helpful? 0
  • +
  • -

#6 oldcrescent  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-August 14

Re: Day of the week,tomorow is...code

Posted 08 August 2014 - 12:10 AM

days= [monday, tuesday , wednesday, thursday, friday, saturday, sunday]
x = day
        print "what day is it today?"
 if day= monday
	print "Tomorrow is tuesday"
if day= tuesday
	print	"Tomorrow is wednesday"
if day= wednesday
 	print "Tomorrow is thursday"
if day= thursday
	print "Tomorrow is friday"
if day= friday
	print "Tomorrow is saturday"
if day= saturday
	print "Tomorrow is sunday"
if day= sunday
	print "Tomorrow is monday"


Was This Post Helpful? 0
  • +
  • -

#7 astonecipher  Icon User is offline

  • Major DIC Head
  • member icon

Reputation: 704
  • View blog
  • Posts: 3,018
  • Joined: 03-December 12

Re: Day of the week,tomorow is...code

Posted 08 August 2014 - 04:57 AM

I think I would pull the value from the entered day and add one. Then determine if that index is greater than 6, to know if you should restart.

days = { Monday => 1, Tuesday =>2}


Using something like that.
Was This Post Helpful? 0
  • +
  • -

#8 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7802
  • View blog
  • Posts: 13,197
  • Joined: 19-March 11

Re: Day of the week,tomorow is...code

Posted 08 August 2014 - 07:10 AM

View Postoldcrescent, on 08 August 2014 - 02:10 AM, said:

days= [monday, tuesday , wednesday, thursday, friday, saturday, sunday]
x = day
        print "what day is it today?"
 if day= monday
	print "Tomorrow is tuesday"
if day= tuesday
	print	"Tomorrow is wednesday"
if day= wednesday
 	print "Tomorrow is thursday"
if day= thursday
	print "Tomorrow is friday"
if day= friday
	print "Tomorrow is saturday"
if day= saturday
	print "Tomorrow is sunday"
if day= sunday
	print "Tomorrow is monday"



This won't even compile, since the variables sunday, monday, etc are referenced before assignment. Also, you're missing the colons in your if statements, and you're using assignment instead of comparison in your if statements.

So it looks to me like you haven't tried very hard at this. Try to come up with code that runs.

Then maybe we'll talk about better ways to get to your goal.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1