Python Forum
Issue Creating New Link Using Text
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue Creating New Link Using Text
#1
Hello, needing some help on an assignment creating a basic web form. I've gone through all the steps where I ask the user three questions. They enter a title, description and then the file name. It should then add this to the web page I have. The last step is to create a link using the name that they entered for the file name and create the file with that file name. Currently my code for that line is:

file.write("""<a href="./reports/"""+postFile+"""">"""+postFile+"""</a>)
When I load the code I get the following error.

There is something wrong with the text of the file you had me try to load.
You may have not have as many closing parentheses as opening parentheses, left the ending quote off of a string, or tried to use a Jython keyword (if, def, etc...) as a function.

If I remove that line of code I can go through the other steps. Not sure what i'm doing wrong here. Any suggestions on how to fix this line or is there something else i'm missing. thanks so much for any tips and assistance.
Reply
#2
Just as the error is saying there is uneven parentheses, you can use ' on the outside to use " on the inside of a string.
change it to '<a href="./reports/'+postFile+'">'+postFile+'</a>' or even better f'<a href="./reports/{postFile}">{postFile}</a>'
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Creating a link that takes the user to a random page card51shor 9 6,043 Jul-06-2020, 05:38 AM
Last Post: card51shor

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020