Backslash, where is it?

Soldato
Joined
27 Mar 2016
Posts
7,468
Location
Bristolian living in Swindon
Hi all

So I'm learning python and getting to grips with Variables, functions etc but one thing I'm not able to do is the \n command for new line....

I can't find Backslash on my keyboard anywhere and tried all the recommendations on Google but nothing seems to work :cry:

Is there an alternative command or does anyone know where my \ is hiding please
 
seems to be between left shift and Z, directly above the windows key
\\\\\\\\


Have you one of those weird 60% keyboards or something rather thana full size

Nooooo full size one bud, will get the missus to try that left shift and Z and let me know as I'm at work... Hopefully it's alright.

@Minibiker - a picture of your actual keyboard, and what Windows keyboard layout you are using may be helpful

I will get one uploaded later if the above doesn't work bud, it's an old keyboard but full size, I don't even know the model I got it for £10 off a friend :cry:
 
Think the only other way in python to put strings on a new line without using \n is to do a separate Print() for each line.

print ('Line 1')
print ('Line 2')

as appose to print ('Line 1 \nLine2')

Basically what I'm trying to do is create a 'shop keeper' and when it offers the products I want them to move to the next line

Print ("what would you like from our menu? \n" + menu)

Something like that


Were you using the onscreen keyboard for inserting those backslashes.

No all on keyboard, didn't know there was a onscreen keyboard
 
menu = {'Apple':1.99,'Beer':3.99,'Bread':0.50}
print('What would you like from our menu ?\n',(menu))

or like this ?

print('What would you like from our menu ?')
print(menu)

I'm no python guru, currently learning this myself :D

Basically like your first print function bud, instead of () around the menu I'd use + menu.... Its known as a concatenate, to add multiple strings together
 
Not the best quality pic for you all to have a look at but this is the keyboard I'm using for now, it's an old model but I can only see one backslash above tab but it doesn't work no matter what I pair with it (Shift, ALT etc)

 
Try the FN key on the bottom row on the right hand side?

Also that KB is all sorts of weird. UK layout but no £ on 3, no “ on 2, I’d just buy a new KB!

Will give that ago thank you... Yeah I will be buying a new one next Monday (payday) this is a piece of **** :cry:
 
Back
Top Bottom