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)
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