I have a list which contain names of students. Example: Read more
Follow this example to create a variable outside functions, and use it inside the functions: MyVariable = 99 #this is a global variable def changeAndPrint_GlobalVariable(): global MyVariable #use global variable in this function with "global" keyword print('Global variable "MyVariable" before changeRead more
Follow this example to create a variable outside functions, and use it inside the functions:
[crayon-686afdcf7ebca954304964/]
This code will print:
[crayon-686afdcf7ebcd096060501/]
You can use Counter if you want to do multiple count of the list from collections import Counter list = ['Jones','Adams','Frank','John','Lopez','Jones','Smith','Ivan','Julian','Carlos','Adams','Frank','Jones','John','Ivan'] print(Counter(list)) Result: Counter({'Jones': 3, 'Adams': 2, 'Frank': 2, 'JRead more
You can use Counter if you want to do multiple count of the list
See less[crayon-686afdcf7e91e369467666/]
Result:
[crayon-686afdcf7e922226403633/]