0

In the following lines of code, the print function seems to ignore the parameter hint I created earlier and want to refer to now. Can someone give me a hint on why?

print("Ah I see, you're stuck. \n"
              "Have a hint.\n"
              "The first three letters are", hint, ".")

hint being a parameter (unsure whether that is the correct name of that) I defined as following: hint = word[0:3], with word being a tuple. Is that maybe the mistake, that I need to refer hint in a tuple like referring manner? Edit: I tried to refer to as "The first three letters are %s." % (hint) as suggested in the linked article and it still does not work.

The output stays

Ah I see, you're stuck. Have a hint. The first three letters are .

I tried many ways, I found on here in this article (article on printing referred parameters, tuples and such.)

Sorry for this simple question, I am just starting out and unfortunately I already mess up this easy stuff.

  • what is `hint`? – eyllanesc Aug 26 '18 at 00:34
  • a variable I defined as following: hint = word[0:3], with word being a tuple. Is that maybe the mistake, that I need to refer hint in a tuple like referring manner? Edit: I tried to refer to as "The first three letters are %s." % (hint) as suggested in the linked article and it still does not work. –  Aug 26 '18 at 00:37
  • 1
    Add all that relevant information to your question, clearly state what you get and what you want to get. read [ask] and improve your question – eyllanesc Aug 26 '18 at 00:38
  • You can use `'''` for multiple line string – Sailesh Kotha Aug 26 '18 at 00:38
  • Edit your question to include the exact definition of `hint`, and the exact output you get from the print. – John Gordon Aug 26 '18 at 00:44
  • [this](https://gist.github.com/dumbledad/bf1e4e59c87ea261182059a9d0c7d0a9) seems to work fine for me – dumbledad Aug 26 '18 at 00:50
  • @JohnGordon done. –  Aug 26 '18 at 00:51
  • @dumbledad what? how can that be? –  Aug 26 '18 at 00:52
  • 1
    We need to see the line where you define `word` and I would include the line where you define `hint` too as @JohnGordon requested – dumbledad Aug 26 '18 at 00:53
  • 1
    With that output, `hint` must be an empty string. It sure would help if you'd show us how `hint` is defined... – John Gordon Aug 26 '18 at 01:04
  • Even tho it work for me but this: `print("Ah I see, you're stuck. \nHave a hint.\nThe first three letters are", hint, ".")` – U13-Forward Aug 26 '18 at 01:06

0 Answers0