Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def reprobado(nombre,archivo):
- reprobo = {}
- contador = 0
- for reprobado in archivo:
- contador +=1
- if contador > 4:
- alumno = reprobado.strip().split(":")
- if nombre in alumno[0] and nombre not in reprobo and len(alumno) == 2:
- reprobo[nombre] = alumno[1]
- elif nombre in alumno[0] and nombre not in reprobo and len(alumno) == 1:
- reprobo[nombre] = "Perdió las ganas de aprobar"
- resultado = reprobo[nombre]
- if reprobo == {}:
- return False
- return resultado
- def agregar( lista, archivo):
- nuevo = open("a.txt","w",encoding="utf-8")
- contador = 0
- for datos in archivo:
- nuevo.write(datos)
- contador += 1
- if contador > 4:
- data = datos.strip().split( ":" )
- flag = True
- if len(data) ==2 and flag == True:
- print( data )
- a = data[0]
- b = data[1]
- nuevo.write("{}:{}\n".format(a,b))
- flag = False
- else:
- nuevo.write( lista[0] )
- if len(lista) >1:
- nuevo.write("{}#{}:{}".format(lista[0],lista[1],lista[2]))
- elif len(lista) == 1:
- nuevo.write(lista[0])
- nuevo.close()
- return len(lista)
- archivo = open( "C:\\Users\\HP\\OneDrive\\Escritorio\\Nueva carpeta (3)\\PyNote.txt","r")
- #print(reprobado("Eduardo Erick", archivo))
- print(agregar(["Alfonso Erick"], archivo))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement