Jump to content

try doing

print(/")

the backslash makes it take the " as a character and cancels its "string" functionality

NEW PC build: Blank Heaven   minimalist white and black PC     Old S340 build log "White Heaven"        The "LIGHTCANON" flashlight build log        Project AntiRoll (prototype)        Custom speaker project

Spoiler

Ryzen 3950X | AMD Vega Frontier Edition | ASUS X570 Pro WS | Corsair Vengeance LPX 64GB | NZXT H500 | Seasonic Prime Fanless TX-700 | Custom loop | Coolermaster SK630 White | Logitech MX Master 2S | Samsung 980 Pro 1TB + 970 Pro 512GB | Samsung 58" 4k TV | Scarlett 2i4 | 2x AT2020

 

Link to comment
https://linustechtips.com/topic/292195-python-error/#findComment-3968654
Share on other sites

Link to post
Share on other sites

Most IDE's are going to do that automatically for you. They assume that certain things, such as brackets have to be closed at some point again anyway, same with Literals / Strings like in your case. You will have to close it at the end again anyway, making it look like this:

 

print ("Hello")

 

So, the IDE fills in the closing bracket and second " for you.

DayZ Forum Moderator, DayZ Developer, ARMA 3: 2017 Developer, System-Admin, Gameserver-Admin, always interested to learn something new as well as new people.

Link to comment
https://linustechtips.com/topic/292195-python-error/#findComment-3968672
Share on other sites

Link to post
Share on other sites

Are you using PyScripter? If so it does that auto matically

Nope, IDLE.

 

try doing

print(/")

the backslash makes it take the " as a character and cancels its "string" functionality

I don't quite understand the string functionality. Any chance you could explain it to me?

It seems impossible until it's done.

Link to comment
https://linustechtips.com/topic/292195-python-error/#findComment-3968673
Share on other sites

Link to post
Share on other sites

That's a forward slash :P

oops sorry i mean to type a backslash

\

 

I don't quite understand the string functionality. Any chance you could explain it to me?

in python doing this "potato" makes potato a string (sentence of text)

the double quotes define what is between them as a string

you cant print it by just doing " because its not a piece of text

 

by putting a backslash before the " you cancel its function turning it into a text character that you can print

NEW PC build: Blank Heaven   minimalist white and black PC     Old S340 build log "White Heaven"        The "LIGHTCANON" flashlight build log        Project AntiRoll (prototype)        Custom speaker project

Spoiler

Ryzen 3950X | AMD Vega Frontier Edition | ASUS X570 Pro WS | Corsair Vengeance LPX 64GB | NZXT H500 | Seasonic Prime Fanless TX-700 | Custom loop | Coolermaster SK630 White | Logitech MX Master 2S | Samsung 980 Pro 1TB + 970 Pro 512GB | Samsung 58" 4k TV | Scarlett 2i4 | 2x AT2020

 

Link to comment
https://linustechtips.com/topic/292195-python-error/#findComment-3968710
Share on other sites

Link to post
Share on other sites

Nope, IDLE.

 

I don't quite understand the string functionality. Any chance you could explain it to me?

 

A string is enclosed in single or double quotes in python. If you want to have the quotes inside the string you can do the following.

# wrap in double quotes, can use single quotes inside the stringprint ("hello'world") # prints hello'world# escape the double quotes so it can be used inside a string with double quotesprint ("hello\"world) # prints hello"world# escape the single quotes so it can be used inside a string with single quotesprint ('hello\'world) # prints hello'world# wrap in single quotes, can use double quotes inside the string without escapingprint ('hello"world) # prints hello"world

Other characters need to be escaped (backslash in front of them) as well.

Link to comment
https://linustechtips.com/topic/292195-python-error/#findComment-3968737
Share on other sites

Link to post
Share on other sites

btw did my solution work? you didnt say if it did :P

NEW PC build: Blank Heaven   minimalist white and black PC     Old S340 build log "White Heaven"        The "LIGHTCANON" flashlight build log        Project AntiRoll (prototype)        Custom speaker project

Spoiler

Ryzen 3950X | AMD Vega Frontier Edition | ASUS X570 Pro WS | Corsair Vengeance LPX 64GB | NZXT H500 | Seasonic Prime Fanless TX-700 | Custom loop | Coolermaster SK630 White | Logitech MX Master 2S | Samsung 980 Pro 1TB + 970 Pro 512GB | Samsung 58" 4k TV | Scarlett 2i4 | 2x AT2020

 

Link to comment
https://linustechtips.com/topic/292195-python-error/#findComment-3968738
Share on other sites

Link to post
Share on other sites

Nope, sorry :( Thanks anyway

try

print("\"")

i might have forgotten the outer doublequotes

NEW PC build: Blank Heaven   minimalist white and black PC     Old S340 build log "White Heaven"        The "LIGHTCANON" flashlight build log        Project AntiRoll (prototype)        Custom speaker project

Spoiler

Ryzen 3950X | AMD Vega Frontier Edition | ASUS X570 Pro WS | Corsair Vengeance LPX 64GB | NZXT H500 | Seasonic Prime Fanless TX-700 | Custom loop | Coolermaster SK630 White | Logitech MX Master 2S | Samsung 980 Pro 1TB + 970 Pro 512GB | Samsung 58" 4k TV | Scarlett 2i4 | 2x AT2020

 

Link to comment
https://linustechtips.com/topic/292195-python-error/#findComment-3968770
Share on other sites

Link to post
Share on other sites

I don't mean there is a problem with the strings, I mean that whenever I enter the " key it prints it twice...

 

Sounds like it's your editor automatically closing the string for you. I don't consider that to be a problem personally. If you don't want that, then you may be able to change your editors settings to stop it.

Link to comment
https://linustechtips.com/topic/292195-python-error/#findComment-3968789
Share on other sites

Link to post
Share on other sites

I don't mean there is a problem with the strings, I mean that whenever I enter the " key it prints it twice...

oooh sorry i misunderstood the issue here...

 

make sure you are using the ' key no the " key,

make sure your editor is not auto-closing strings

and try copy pasting ' instead of typing, see if that changes anything

NEW PC build: Blank Heaven   minimalist white and black PC     Old S340 build log "White Heaven"        The "LIGHTCANON" flashlight build log        Project AntiRoll (prototype)        Custom speaker project

Spoiler

Ryzen 3950X | AMD Vega Frontier Edition | ASUS X570 Pro WS | Corsair Vengeance LPX 64GB | NZXT H500 | Seasonic Prime Fanless TX-700 | Custom loop | Coolermaster SK630 White | Logitech MX Master 2S | Samsung 980 Pro 1TB + 970 Pro 512GB | Samsung 58" 4k TV | Scarlett 2i4 | 2x AT2020

 

Link to comment
https://linustechtips.com/topic/292195-python-error/#findComment-3968818
Share on other sites

Link to post
Share on other sites

I don't mean there is a problem with the strings, I mean that whenever I enter the " key it prints it twice...

Just use ' instead of ". You don't have to shift and it functions in the same way. Make it a habit, it'll be a good one.

CPU: AMD FX-6300 4GHz @ 1.3 volts | CPU Cooler: Cooler Master Hyper 212 EVO | RAM: 8GB DDR3

Motherboard: Gigabyte 970A-DS3P | GPU: EVGA GTX 960 SSC | SSD: 250GB Samsung 850 EVO

HDD: 1TB WD Caviar Green | Case: Fractal Design Core 2500 | OS: Windows 10 Home

Link to comment
https://linustechtips.com/topic/292195-python-error/#findComment-3968995
Share on other sites

Link to post
Share on other sites

It still prints two ' :(

Get a new text editor. Try out Notepad++

CPU: AMD FX-6300 4GHz @ 1.3 volts | CPU Cooler: Cooler Master Hyper 212 EVO | RAM: 8GB DDR3

Motherboard: Gigabyte 970A-DS3P | GPU: EVGA GTX 960 SSC | SSD: 250GB Samsung 850 EVO

HDD: 1TB WD Caviar Green | Case: Fractal Design Core 2500 | OS: Windows 10 Home

Link to comment
https://linustechtips.com/topic/292195-python-error/#findComment-3969420
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×