+ 3

Concatenation in Python

Hello Sololearners, Let's assume I assigned 'ip' and 'port' the value of '192.168.20.2' and '80' respectively. How can I print "The IP address is 192.168.20.2 and the Port number is 80" on Python 3.7

12th Feb 2019, 2:00 PM
Chidera Anichebe
Chidera Anichebe - avatar
4 Respostas
+ 8
ip = '192.168.20.2' port = '80' print('The IP address is', ip, 'and the Port number is', port) print('The IP address is ' + ip + ' and the Port number is ' + port) print('The IP address is %s and the Port number is %s' % (ip, port)) print(f'The IP address is {ip} and the Port number is {port}') print('The IP address is {} and the Port number is {}'.format(ip, port))
12th Feb 2019, 2:11 PM
Anna
Anna - avatar
+ 9
Print("ip address is {0} and port {1}").format(ip,port)
12th Feb 2019, 2:09 PM
Hubert Dudek
Hubert Dudek - avatar
+ 2
12th Feb 2019, 2:11 PM
Chidera Anichebe
Chidera Anichebe - avatar
+ 2
Anna I missed the commas. Thanks
12th Feb 2019, 2:14 PM
Chidera Anichebe
Chidera Anichebe - avatar