1

This is a program intended to write text to any file specified

var_file = (raw_input('nof$ ') #nof, number of files.
try:
    text = str(raw_input('ttwtf$ ') #ttwtf, text to write to files.
    print text >>> var_file
except ValueError:
    print "Error: Not a string"
    main()

When the program starts the "try" part of the program it returns a syntax error. No details, just:
"SyntaxError: Invalid syntax"

Whats wrong?

6
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by HiHe
0

There are unbalanced parenthesis at lines 1 and 3 ...

SyntaxError usually means a very simple issue: most of the time an unbalanced parenthesis, sometimes a missing comma or colon ;)

0

Try this code:

var_file = (raw_input('nof$ ')) #nof, number of files.
try:
    text = str(raw_input('ttwtf$ ')) #ttwtf, text to write to files.
    print text >>> var_file
except ValueError:
    print "Error: Not a string"
    main()
0

Mild corrections to make this work:

var_file = raw_input('nof$ ') #nof, number of files.
try:
    text = raw_input('ttwtf$ ') #ttwtf, text to write to files.
    print text, ">>> ", var_file
except ValueError:
    print "Error: Not a string"
    #main()
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.