0
Regarding Input
print ("Hello, Python!") print("test") x = int(input('''insert: ''')) def y(x): x+=1 return x print (y(x)) Above is the code i type, i'm curious about why the input i gave will be move below the word "insert" when i break the input code in to two parts. It gave me Hello, Python! test insert: 2 Why is the "2" below the word insert? Shouldnt it be beside the word "insert"?
5 odpowiedzi
+ 1
If you don't want the newline but the line in your code is full and you want to split it, you can (for example) write:
x = int(input(
'insert:'))
Like this you have no string with newlines and the output is as if you wrote it in one line.
+ 1
Alright got it! Thanks for both of your help!
0
remove the line break after: on line starting with x=int...
change to
x=int(input('insert: '))
0
Can i know what's the difference between them?
0
The triple apostrophes is used for multiline
in your code you have
x = int(input('''insert:
'''))
so it preserves the line break after the :