E
E
enabl32018-05-30 07:40:37
Python
enabl3, 2018-05-30 07:40:37

python string input/output?

Hello.
The question is most likely the simplest, but I just can’t figure it out, please help or tell me how to be right.
At the input we have a list with several data, let it be: Vasya Petya Serezha, etc.
How to get data in the output format:
Vasya
Line 1
Petya
Line 2
..............
Serezha
Line N
I would be very grateful.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nick V, 2018-05-30
@enabl3

for index, item in enumerate(['вася', 'петя', 'саша'], start=1):
    print(f'{item}\nСтрока № {index}')

import ipaddress

mac_addresses = ['aa:bb:cc:aa:bb:11', 'aa:bb:cc:aa:bb:12', 'aa:bb:cc:aa:bb:13', 'aa:bb:cc:aa:bb:14', 'aa:bb:cc:aa:bb:15']
start_ip = ipaddress.ip_address('192.168.0.11')

for index, mac_address in enumerate(mac_addresses):
    print(f'MAC {mac_address}\nIP {start_ip + index}\n')

Conclusion:
MAC aa:bb:cc:aa:bb:11
IP 192.168.0.11
MAC aa:bb:cc:aa:bb:12
IP 192.168.0.12
MAC aa:bb:cc:aa:bb:13
IP 192.168.0.13
MAC aa :bb:cc:aa:bb:14
IP 192.168.0.14
MAC aa:bb:cc:aa:bb:15
IP 192.168.0.15

A
aderes, 2018-05-30
@de-iure

n = 0
for i in ['вася', 'петя', 'саша']:
    n += 1
    print(f'{i}\nСтрока № {n}')

Vasya
Line No. 1
Petya
Line No. 2
Sasha
Line No. 3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question