Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
me again...:)
#1
ok for once this is not for homework but to make my output look better

    elif option == 3:
        for item in FAQ:
            print("Question: ", item)
            print("Answer: ", FAQ[item])
this is part of my assignment which I think is pretty easy this week. When I print it out I want to have some space between each set of FAQ/answers
like this:

current output:
Question:
Answer:
I want :
Question:

Answer:
Also when I print the dictionary they will all be on top of each other so I want to space that aswell.

Thanks in advance. Again this is not part of the homework it comes out just like it should for school work purposes I just want it cleaner
Reply
#2
Have you covered format yet? Having your string with braces, and a \n after the braces followed by the appropriate format statement should fix you right up.
Reply
#3
(Aug-06-2019, 09:35 PM)jefsummers Wrote: Have you covered format yet? Having your string with braces, and a \n after the braces followed by the appropriate format statement should fix you right up.

Not fully, Im not sure what you mean so I think my desire for neatness will have to wait.....lol
I have other issue with the code im trying to fix so I will work on this later


Thanks
Reply
#4
Well, if you haven't covered format by itself, note that print() by itself will print a blank line. Also \n in a string represents a new line, so print('\nQuestion:') will print a blank line before the word 'Question'.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
(Aug-06-2019, 10:20 PM)ichabod801 Wrote: Well, if you haven't covered format by itself, note that print() by itself will print a blank line. Also \n in a string represents a new line, so print('\nQuestion:') will print a blank line before the word 'Question'.

yep that was easy thanks and it cleans it up
Reply


Forum Jump:

User Panel Messages

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