If you have any questions, comments or issues with this project please post them here!
following the tutorial, but using multiple .replace() like this
page.replace("{name}", myName)
doesn’t work when i try it, only
page=page.replace("{name}", myName)
does. a miniscule issue but i still wonder why that is? i’m only copypasting from the tutorial.
This doesn’t work because strings in Python are immutable, once they are saved to memory they cannot be changed. When using page = page.replace("{name}", myname)
, you are creating a new string, separate to the old string. You can check this by using the id()
function.
I’m having an issue with reflection showing in link form where there’s no href in html for that part… any thoughts? Thanks
and for some reason it’s not pulling my style.css file either
Hi @Thrsh001 sorry for the delay in responding to this. Can you share a link to your Repl please?
I am on day 77 and I absolutley could not figure out what to do and even when I copypasted the code from the solution it did not work
here is the link:
https://replit.com/@DavidAtReplit/Day-077-Solution?v=1
pls help @DavidAtReplit
Can you post a link to YOUR repl link please? The one posted is David’s.
Thanks @Sai-GiridharGi1
Looking at your code this stands out:
@app.route('/')
def index():
page = ""
return page
as in the tutorial it says you should have:
@app.route('/')
def index():
myName = "Katie"
page = ""
f = open("template/portfolio.html", "r")
page = f.read()
f.close()
page = page.replace("{name}", myName) # Replace all instances of {name} with the contents of the 'myName' variable
return page
(obviously you’ll have to change portfolio.html
to blog.html
for the challenge)
I see that the solution @DavidAtReplit posted matches your code at the moment and this will be corrected soon, however it is a challege for you to work out using the tutorial as a guide so with a little reading back through the tutorial you should have been able to work this out.
Hope the above explanation helps point you in the right direction.
Yes, But you see I already did that in the app route “/hello” and when you type in /hello at the end of the url. the replace function is not replacing it.
Nevermind, it worked when I did
page = page.replace("blank",blank)
thanks a lot!