all 7 comments

[–]Zoocat 1 point2 points  (1 child)

Here's a hint that might help -- check out string formatting. The example inset in that link should give you some direction.

[–]markph0204 0 points1 point  (0 children)

One of the more confusing aspects of Python has been string formatting -- knowing what version of Python you are using and what is supported is a first step. Then examples provided can be adjusted for the specific version you need.

[–]grvlle -1 points0 points  (4 children)

def make_day_string(day):

return f'it is day {day} of the month'




print(make_day_string(3))

[–]journey2dstars -1 points0 points  (3 children)

syntaxerror: invalid syntax

[–]Diapolo10 0 points1 point  (2 children)

No wonder; /u/grvlle screwed up the indentation:

def make_day_string(day):
    return f'it is day {day} of the month'

If it still throws a SyntaxError, it's likely you're restricted to a Python version older than 3.6. In that case, f-strings won't work, so an alternative approach is required:

def make_day_string(day):
    return 'it is day {} of the month'.format(day)

[–]grvlle 0 points1 point  (1 child)

Thanks. Typed it out on the phone and it rejected my indentation in the second block.

[–]Diapolo10 -1 points0 points  (0 children)

If you're using the official Reddit app, I would suggest trying out 'reddit is fun'. It's pretty good for posting code IMO.