Hey guys,
I have some code here which checks the last three characters in the list:
site_list=
['C', ':', '\\', 'D', 'o', 'c', 'u', 'm', 'e', 'n', 't', 's', ' ', 'a', 'n', 'd', ' ', 'S', 'e', 't', 't', 'i', 'n', 'g', 's', '\\', 'S', 'r', 'a', 'v', 'a', 'n', '\\', 'M', 'y', ' ', 'D', 'o', 'c', 'u', 'm', 'e', 'n', 't', 's', '\\', 'M', 'y', ' ', 'M', 'u', 's', 'i', 'c', '\\', 'T', 'a', 'p', 'h', 'a', ' ', 'N', 'i', 'a', 'n', 'g', '.', 'm', 'p', '3']
def check_dot():
p=0
for a in site_list:
if a=='.':
p=site_list.index('.')
for b in site_list:
s3=''.join(site_list[p])
p+=1
if (p>len(site_list)):
break
check_dot()
I used the above code to check whether the list ends with a '.mp3' or '.exe', is my code right? Any more ideas on how I can shorten it?