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"?

6th Aug 2018, 7:50 PM
Chen Chee Kin
5 Answers
+ 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.
6th Aug 2018, 9:43 PM
HonFu
HonFu - avatar
+ 1
Alright got it! Thanks for both of your help!
7th Aug 2018, 4:12 PM
Chen Chee Kin
0
remove the line break after: on line starting with x=int... change to x=int(input('insert: '))
6th Aug 2018, 7:58 PM
Louis
Louis - avatar
0
Can i know what's the difference between them?
6th Aug 2018, 7:59 PM
Chen Chee Kin
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 :
6th Aug 2018, 8:12 PM
Louis
Louis - avatar