Reputation: 77
I am using nested for loops to check if the substring "f" is present in one of the permutation of given string as parameter in the following function.
import itertools
def permute(f,string):
permutation_list = []
permutations = itertools.permutations(string)
for item in permutations:
permutation_list.append(''.join(item))
for item in permutation_list:
if f in item: # unindentation error
print "YES"
break
else:
print "NO"
break
if __name__ == "__main__":
t1=input()
for i in range(0,t1):
a=raw_input()
b=raw_input()
c=a+b
print c
t2=input()
f=""
for j in range(0,t2):
d=raw_input()
f=f+d
permute(f,c)
It is giving unindentation error at line 10
Upvotes: -1
Views: 3753
Reputation: 174624
A few possibilities:
A good Python-aware text editor should highlight these for you and offer a quick fix.
Here is a fixed version:
import itertools
def permute(f,string):
permutation_list = []
permutations = itertools.permutations(string)
for item in permutations:
permutation_list.append(''.join(item))
for item in permutation_list:
if f in item: # unindentation error
print "YES"
break
else:
print "NO"
break
if __name__ == "__main__":
t1=input()
for i in range(0,t1):
a=raw_input()
b=raw_input()
c=a+b
print c
t2=input()
f=""
for j in range(0,t2):
d=raw_input()
f=f+d
permute(f,c)
Upvotes: 2