I want to enter a number in n, enter a word from the keyboard according to the number, and then display',' between the words and'.' At the end of the sentence.
As a specific example
n = 2
When you enter
I want to output as follows.
It may be difficult to understand with poor sentences, but please explain.
The word entered in a is stored, but since the word is decomposed and stored character by character,'.' Does not appear where I want to display'.'.
n = int (input ())
a = ""
for i in range (n):
a + = input ()
if a == a [-1]:
a + = "."
a + = ","
To store the character string stored in a as one word
b = [a]
As a result
It became like ['A','m','m','r','i','c','a' ....'d','i','a']
Please provide more detailed information here.
Answer # 1
Prepare a list in advance and add the words received by input () to the list.
''. Join (Sequence)It is possible to concatenate the character strings in the list with.
It is also possible to separate them with a specified character string and concatenate them. If you want to separate them with commas, you can specify them.
And if you want to put the end of the sentence in a period
print (end ='.')You can output the end of the sentence with a period.
n = int (input ()) lst =  for i in range (n): lst.append (input ()) print (','. join (lst), end ='.')
Answer # 2
I want to change the process only the last time, so
if a == a [-1]:
if i == n-1:
- numpy - [python] i want to combine alternately and make two sets of two arrays of latitude and longitude
- python - i want to combine cnn layers with keras
- python - pytorch i want to combine two models
- python: why use popleft instead of pop in breadth-first search
- python 3x - i want to extract only strings and numbers from a data frame (object type) that contains a mixture of strings, numbe
- python - i want to use the stack to reverse the strings, but an error occurs, so please give me a solution
- python - is it possible to combine duplicate index and columns in pandas and add the numbers in them?
- python - displaying the pygame window
- python 3x - how to combine the xth character to the yth character of the data read by pandas
- listing strings in python
- about python strings
- python - i want to combine the dataframe of multiindex column of padas and the dataframe of single column
- python - i want to combine point sequences with almost the same x coordinates into one
- python - about the solution when "list the strings separated by commas, but do not use the commas contained in the characte
- cannot combine python pdf files (multiple processing using excel list and for statement)
- python expected 1d or 2d array, got 3d array instead error in function creation
- about the code to combine in python
- python 3x - i want to combine a large number of csv files in the line direction
- i want to combine split images using cv2 (python)
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- python - you may need to restart the kernel to use updated packages error
- python 3x - typeerror: 'method' object is not subscriptable
- xcode - pod install [!] no `podfile 'found in the project directory
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- android studio - unresolved reference comes out in kotlin