PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label quotation-marks. Show all posts
Showing posts with label quotation-marks. Show all posts

Wednesday, August 17, 2022

[FIXED] How to run a Racket program without output being quoted?

 August 17, 2022     output, quotation-marks, racket, scheme, string     No comments   

Issue

I have a basic Racket program:

hello.rkt:

(write "Hello, World!")

When I run it with racket -f hello.rkt, I get the following output:

"Hello, World!"

Is there a special compiler flag, or special version of "write/print" that removes the quotes from string output, so that it shows:

Hello, World!

Solution

The write function is the dual to read: it outputs (or at least attempts to output) datums that could be read back in to produce the original value. In my experiences, it is not often terribly useful even for that purpose, but it can be helpful when you’re debugging.

For actual output, the function you want is display. This outputs the actual data itself to the output port, not a formatted representation of it.


For completeness, Racket has an additional printing function, called print. Unlike display and write, print is explicitly designed to be used for debugging. Its output can be customized by a variety of different parameters, so the output format is uses it not necessarily predictable, and it shouldn’t be used for anything other than debugging. For that purpose, though, it’s quite useful.



Answered By - Alexis King
Answer Checked By - Terry (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, August 14, 2022

[FIXED] How to print variable inside quotation marks?

 August 14, 2022     output, python, quotation-marks     No comments   

Issue

I would like to print a variable within quotation marks. I want to print out "variable"

I have tried a lot, what worked was:

print('"', variable, '"')

but then I have two spaces in the output:

" variable "

How can I print something within a pair of quotation marks?


Solution

you can use format:

>>> s='hello'
>>> print '"{}"'.format(s)
"hello"

Learn about format here:Format

In 3x you can use f:

>>> f'"{s}"'
'"hello"'


Answered By - Hackaholic
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing