hey guys here is my question.. i have two txt files which contains men and women names.. as: Show
i managed stripping to ":" but i can't write them side by side in a list..
how can i do it as in the expected output.. thanx in advance :) this is my sample file..
ant man,frodo,star... is the men mame.. and what i want to append a list.. View Discussion Improve Article Save Article View Discussion Improve Article Save Article Printing a list in python can be done is following ways:
Python
Python
Output 1 2 3 4 5 printing lists separated by commas 1, 2, 3, 4, 5 printing lists in new line 1 2 3 4 5
Python
Output Geeks for Geeks 1, 2, 3, 4, 5
Python
Output 1 2 3 4 5 in new line 1 2 3 4 5
Python3
Output 1 2 3 4 5 In new line 1 2 3 4 5 How do you print elements side by side in Python?Without using loops: * symbol is use to print the list elements in a single line with space. To print all elements in new lines or separated by space use sep=”\n” or sep=”, ” respectively.
How do you print lists next to each other in Python?You can use the zip() function to join lists together. The zip() function will iterate tuples with the corresponding elements from each of the lists, which you can then format as Michael Butscher suggested in the comments. Finally, just join() them together with newlines and you have the string you want.
How do you print a list of elements on the same line in Python?When you wish to print the list elements in a single line with the spaces in between, you can make use of the "*" operator for the same. Using this operator, you can print all the elements of the list in a new separate line with spaces in between every element using sep attribute such as sep=”/n” or sep=”,”.
How do I print two lists of elements in Python?Method 2: Add two list using the Comprehension List. # initialize the Python lists.. lt1 = [2, 4, 6, 8, 10, 30]. lt2 = [2, 4, 6, 8, 10, 12]. # print the original list element.. print ( " Python list 1 : " + str (lt1)). print ( "Python list 2 : " + str (lt2)). # use list comprehension to add two lists.. |