Author Archive: admin
While Loops
For Loops

There is two type of loop in Python, For loops and While Loops. For Loops ips = [“10.10.10.1”, “10.10.10.2”, “10.10.10.3”, “10.10.10.4”] for each_ip in ips: ….print(each_ip) 10.10.10.1 10.10.10.2 10.10.10.3 10.10.10.4 Another example : devices = [“device1”, “device2”] for each_host in…
Read more
Booleans
Conditionals
Dir, Help, and Variables

To see all option available for your variable : dir(variable) will show you all available set of methods or other attributes. to be able to use the method or attribute you need to use the name and add (). By…
Read more
Linters
Split() & Join()
List Slices

While opening a file as an example. while open(“ext.ext”, “r”) as f: ….output = f.readlines() ….len(output) ….print(output[0:5]) This would create a list and 1 element per lines The Len would be the total of element in the list The output…
Read more
Lists

Creating a list in Python my_list = [ ] type(my_list) my_list = [‘haha’, ‘100’, 100, 2.0] To access element from a list you can choose each of them starting by element 0 my_list[0] haha my_list[3] 2.0 To change an element…
Read more