On 12/04/18 18:24, Scharrer, Brianna wrote: What appears below seems to be an assignment of some kind. We do not do your work for you although we will offer help. But it is best if you show us your work so far, or at least describe how you intend to tackle it.
In this case you are being given a string and need to convert it to a different format. It is not clear how you should expect to "be given" the input data but I assume you can read it from a user? In Python you have many string methods to help you slice/split the input into its parts. Look at the slice operations and the split method. Given the fixed lengths involved here slicing is probably easiest. The assignment suggests "casting" the string to integers but I think this is poor terminology and what is meant is that you should convert the substrings into integers (casting and conversion are very different things!). Get back to us when you have something to show us or a specific query. > Applications of basic language syntax > > Date/time string parsing > > Time stamps on data are often recorded in the standard ISO date and time > format as shown below > > yyyy-mm-ddThh:mm:ss > > 2018-01-02T18:31:16 ----> 6:31pm on January 2, 2018 > > 1999-02-14T21:02:37 ----> 9:02pm on February 14, 1999 > > > Write code that when given a datetime string and outputs a human readable > version exactly in the format specified below. > > [Morning, Noon, Afternoon, Evening, or Night], X:XX[am or pm] on [Month as a > word] [day], [year] > > E.g. 1999-02-14T21:02:37 would be “Night, 9:02pm on February 14, 1999” > > Do not use any datetime string function, though depending on your language > they would be useful to do this in practice. > > Hint: you’ll have to cast strings to integers in order to perform the if > statements which place [Morning, Noon…], [am or pm] and [Month as a word] > appropriately. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor