Error in Python IndentationError: unindent does not match any outer indentation level

0

I have this code in Python version 3.6

#! /usr/bin/python
#-*- coding: utf-8 -*-

import pxssh

usuario = open("usuario.txt", "r")

for usuario in usuario.read().split("\n"):
    password = open("password.txt", "r")
    for password in password.read().split("\n"):
        try:
            conectar=pxssh.pxssh()
            conectar.login("localhost",  str(usuario), str(password))
            print "Usuario y Password correcto es:"
            print "[+] Usuario: {}". format (usuario)
            print "[+] Password: {}". format (password) 

    except :

        print "[-] Usuario y Password Incorrecto"
        print "[-] Usuario {}". format (usuario)
        print "[-] Password {}". format(password)

The problem is the error that he sends me when trying to execute the program which is

  

File "program.py", line 14        print "User and correct password is:"                                              ^ IndentationError: unindent does not match any outer indentation level

I already searched the internet and I could not find an answer. Help is appreciated.

    
asked by Juan Vial 17.10.2018 в 03:31
source

1 answer

2

The problem is that your line except is out of the condition, remember that try and except must go to the same level. Since it is the same process so to speak.

import pxssh

usuario = open("usuario.txt", "r")

for usuario in usuario.read().split("\n"):
    password = open("password.txt", "r")
    for password in password.read().split("\n"):
        try:
            conectar=pxssh.pxssh()
            conectar.login("localhost",  str(usuario), str(password))
            print ("Usuario y Password correcto es:")
            print( "[+] Usuario: {}". format (usuario))
            print ("[+] Password: {}". format (password))

        except :

            print( "[-] Usuario y Password Incorrecto")
            print ("[-] Usuario {}". format (usuario))
            print ("[-] Password {}". format(password))
    
answered by 17.10.2018 в 04:33