Difference among list, tuple and set in Python and when to use each one

Python has three similar data structures that can hold an unordered collection of elements: list, tuple and set. Here's how they differ: initialization list: using the built-in list() or the square brackets ([]): list1 = list() # creates an empty list list2 = [] # also creates an empty list list3 = ['a', 'b', 'c', … Continue reading Difference among list, tuple and set in Python and when to use each one

Add a filename in the command line when running a Python script

OR: Run a Python script with arguments You can add arguments to the command line when running python scripts by importing the sys module from Python's standard library and using its argv function. Some examples: A simple script that displays the user name: def main(): name = 'Frodo' print(f'Hello, {name}') if __name__ == "__main__": main() … Continue reading Add a filename in the command line when running a Python script