On 05/02/2019 12:32, Sonia Miglani wrote: > OS Linux > Python version 2.7.13
Can you tell us how you are creating the file? Which editor are you using? It looks like there may be some spurious characters in your file. > def demo(s, exclaim): > # """ > # Returns the string 's' repeated 3 times. > # If exclaim is true, add exclamation marks. > > > result = s + s + s > if exclaim: > result = result + '!!!' > return result > > > def main(): > print demo('Yay', False) ## YayYayYay > print demo('Woo Hoo', True) ## Woo HooWoo HooWoo Hoo!!! It all works perfectly for me. > Error: > ./python2.py: line 1: syntax error near unexpected token `(' > ./python2.py: line 1: `def demo(s,exclaim): Notice the odd backtick (`) characters? They aren't in your code above, did you retype it or actually copy/paste your real code? It is important that you post the actual code you get the error from. -- 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