Saturday, August 8, 2020

Writing Functions and Importing Custom/System Functions

 

                    Writing Functions and Importing Custom/System Functions


# writing custom function to find index 

print('Imported testp...')


def find_index(to_search, target):
'''Find the index of a value in a sequence'''
for i, value in enumerate(to_search):
if value == target:
return i

return -1



# Import sys module and printing all System Path.

import sys
print(sys.path)

# Import OS module and print location of file where the function is defined.

import os
print(os.__file__)

No comments:

Post a Comment