I\'m having an issue with string substitution. *** randomquote and randompic are
ID: 3932513 • Letter: I
Question
I'm having an issue with string substitution.
*** randomquote and randompic are both indexes of lists set to variables.
***there IS tab before the print(""" it just won't show up when I post the question.
Here is what I have:
print("""
<html>
<head>
<title>Quote and Image of the Day of Mario Batali</title>
</head>
<body>
Quote: %s
Pic: <img src '%s' width = 100 height = 7>
</body>
</html>
""" %s = (randomquote, randompic))
I keep getting an error with the %s = (randomquote, randompic)) saying that it "Keyword can't be an expression"
Can someone suggest an alternative to help get past this? Thanks
Explanation / Answer
"""
Remove %s at the end of the print statement.
I have taken some sample input's for randomquote and randompic, you can remove that.
"""
randomquote = "Hello World!"
randompic = "PIC"
print("""
<html>
<head>
<title>Quote and Image of the Day of Mario Batali</title>
</head>
<body>
Quote: %s
Pic: <img src '%s' width = 100 height = 7>
</body>
</html>
""" %(randomquote, randompic))
"""
sample output
"""
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.