-1

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

5
  • 1
    Make sure you didn't mix tabs and spaces. Commented May 12, 2013 at 15:37
  • 1
    try python -tt filename.py to run your code. Commented May 12, 2013 at 15:39
  • @AshwiniChaudhary It is still giving same error Commented May 12, 2013 at 15:41
  • Check line permutation_list.append(''.join(item)) for tabs. Commented May 12, 2013 at 15:42
  • The code you have in your question does not give that error. You have a couple things wrong, though, that still prevent the code from working. For example, all the code starts with indentation; the first level of indentation should be at the left margin. Also, the code under your if __name__... statement is indented improperly. When I fix those, your code works fine. Commented May 12, 2013 at 15:48

1 Answer 1

2

A few possibilities:

  1. You have all other indents at 3 spaces, but your highlighted line is indented 4 spaces.
  2. You have mixed tabs and spaces.
  3. You didn't start at the first column.

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) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.