Elimde 3 satırlık metinler var. Bunu direkt scripte yapıştırdığımda bana her satır listenin bir elemanı olacak şekilde ayırması lazım. Bunu nasıl yapabilirim?
(Ayrı ayrı stringler haline getirmek de işimi görür, eğer bunu biliyorsanız onu da yazabilirsiniz. Asıl önemli olan bir satır boşluk olan metni satırlarına ayırabilmek.)
I want to write a program that gets multiple line input and work with it line by line. Why isn't there any function like raw_input in Python 3? input does not allow the user to put lines separated by
stackoverflow.com
Yukarıda verilen kodu değiştirdim:
Python:
print("Enter/Paste your content. Ctrl-D or Ctrl-Z ( windows ) to save it.")
contents = []
while True:
try:
line = input()
except EOFError:
break
if line != "":
contents.append(line)
print(f"list = {contents}")
Metni yapıştır, ardından önce Enter sonra Ctrl-D/Ctrl-Z yap.
I want to write a program that gets multiple line input and work with it line by line. Why isn't there any function like raw_input in Python 3? input does not allow the user to put lines separated by
stackoverflow.com
Yukarıda verilen kodu değiştirdim:
Python:
print("Enter/Paste your content. Ctrl-D or Ctrl-Z ( windows ) to save it.")
contents = []
while True:
try:
line = input()
except EOFError:
break
if line != "":
contents.append(line)
print(f"list = {contents}")
Metni yapıştır, ardından önce Enter sonra Ctrl-D/Ctrl-Z yap.