How do I make a multi-line input in python without using a list?

Question:

I have to write a program without using list(as I still haven’t learnt them) to take 10 names as the input and put them all in lower-case and then capitalize the first letter.
I came up with two programs that both work; However, there are some problem!
the first programs is:

text=input()
x=text.split()
for name in x:
    x=name.lower().capitalize()
    print(x)

in the above program I can only take the names in one line and if the user presses enter in order to type the new name in a new line the program would think that the input is over and all.
so I searched the internet and found readlines() method but I have no idea how to put a limit to the inputs and I do it manually with "ctrl+z", is there a way I can put a limit to it?
the second program is as below:

import sys
text=sys.stdin.readlines()
for esm in text:
    x=esm.lower().capitalize()
    print(x)
Asked By: Annahita

||

Answers:

If it’s 10 the number of lines to be introduced then use a for loop

for _ in range(10):
    name = input().title()
    print(name)

the _ in the loop means you don;t need to keep the variable (you just need to iterate 10 times)

.title makes a string lowercase except for the first character which will be uppercase

Answered By: Sembei Norimaki

It is still not entirely clear what exactly you want to do and why you say that you want to do it "without lists" but show examples of you doing it with lists. Anyway, here is a guess as to what you might be looking for:

def main():
    string = input("Type in names (separated with spaces): ")
    for name in string.split():
        print(name.title())


if __name__ == '__main__':
    main()
Answered By: Daniil Fajnberg

All answers are probably viable however in the case that there is no name you don’t want to add an empty name to your text do you? In that case you need to do it like this:

text = ""
i = 0
while i < 10:
    x = input()
    if x != "":
        text += x + SEPARATOR # ยง is the separator, you can use anything
        i += 1

for t in text.split(SEPARATOR):
    print(t.title())
Answered By: eisa.exe

You could do it like this:

t = ''

for i in range(10):
    name = input(f'Input name {i+1}: ')
    t += name + 'n'

print(t, end='')
Answered By: Vlad