Day 077 - Project 77 : New pages blog + url shortener

If you have any questions, comments or issues with this project please post them here!

1 Like

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.

1 Like

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

1 Like

Hi @Thrsh001 sorry for the delay in responding to this. Can you share a link to your Repl please?

1 Like

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:
pls help @DavidAtReplit

Hi @Sai-GiridharGi1

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:

def index():
  page = ""
  return page

as in the tutorial it says you should have:

def index():
  myName = "Katie"
  page = ""
  f = open("template/portfolio.html", "r")
  page =
  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.

1 Like

Screenshot 2023-07-24 151514
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!

1 Like

@DavidAtReplit Just a headsup, it would be good to fix the 077 replace lines in the code as they are currently faulty.
eg: page.replace("{name}", myName) needs to be fixed to page = page.replace("{name}", myName)

1 Like

Also the solution replit is 404

1 Like

Yes this works now, I’ve been scratching my head over this but it’s staring at me!