Python - Hackerrank learnings
- supriyamalla
- Jul 13, 2020
- 1 min read
Difference between Sorted() and Sort()
Read this
Printing a list:
Credits: geeksforgeeks.org
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.
filter_noneedit play_arrow brightness_4 # Python program to print list # without using loop a = [1, 2, 3, 4, 5] # printing the list using * operator separated # by space print(*a) # printing the list using * and sep operator print("printing lists separated by commas") print(*a, sep = ", ") # print in new line print("printing lists in new line") print(*a, sep = "\n")
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
Textwrap in Python:
Read this
Commentaires