473,387 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Printing out an answer in quotes

Thekid
145 100+
Hi, how can I get an answer to print out in quotes? Example is of a math question in which the answer prints out in this format:
print answer
>>>15

The answer varies with each question and I'd like it to print out like this:
>>>'15'

How can I get the quotes added in? Thanks
Jan 25 '08 #1
3 1174
Thekid
145 100+
I think I figured it out:

Expand|Select|Wrap|Line Numbers
  1.  
  2. print " '%s' " % answer
  3.  
  4.  
Jan 25 '08 #2
dazzler
75
you can print it also this way:

Expand|Select|Wrap|Line Numbers
  1. print " ' ", answer, " ' "
  2.  
Jan 29 '08 #3
elcron
43
You can escape quotes with "\" but it usually better to avoid it unless you're nesting multiple layers of quotes.
Expand|Select|Wrap|Line Numbers
  1. >>> print "\""
  2. "
  3. >>> answer = 15
  4. >>> print "\"%s\""%(answer)
  5. "15"
  6.  
Jan 31 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Thomas Philips | last post by:
I want to print "1 spam 4 you" using a formatted string that gets its inputs from the dictionary d={'n1':1, 's1':'spam', 'n2':4}. To do so, I write >>> x="%('n1')d %('s1')s %('n2')d you" >>> x...
5
by: Mark Preston | last post by:
Admission first - I don't actually have a problem here but have noticed that a lot of people have been asking similar questions and getting very varied answers. What I've done is to sort of...
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
2
by: Ryan Gregg | last post by:
I've got a dot matrix printer that I need to print a line at a time to. This is being used for an audit log on an application and every event that occurs needs to print out right as it occurs. ...
10
by: Jeff B. | last post by:
Has anyone come across a decent algorithm for implementing word wrap features in .net printing? I have a small component that uses basic printing techniques (i.e. e.Graphics.DrawString in a...
2
by: yulyos | last post by:
Hi Answer To Printing from Right To Left To The Printer in VB.NE Printing From Right To Left To The Printer in VB.NE you can download a small example http://www.geocities.com/vmtnl/rtl.htm...
7
by: nikou_70 | last post by:
I have a html page, I want to user can print it, I don't know how I can fix margin for page that user can print page without manipulate top or left margins, now printing in each computer different...
35
by: Mokkapati | last post by:
Hi all, I have data that has to be written successively, that is, this data is updated at every step in the loop and I need to print this in a file. So, I need something like, for every step,...
2
by: =?Utf-8?B?Umlja1NlYW4=?= | last post by:
I have a long form within a panel which exceeds the maximum height of 876. I use the following code to print the form but it prints only the portion of the form that is displayed on the screen (max...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.