Advertisement
Matblinx

Untitled

Jul 17th, 2021
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. def reprobado(nombre,archivo):
  2. reprobo = {}
  3. contador = 0
  4. for reprobado in archivo:
  5. contador +=1
  6. if contador > 4:
  7. alumno = reprobado.strip().split(":")
  8. if nombre in alumno[0] and nombre not in reprobo and len(alumno) == 2:
  9. reprobo[nombre] = alumno[1]
  10. elif nombre in alumno[0] and nombre not in reprobo and len(alumno) == 1:
  11. reprobo[nombre] = "Perdió las ganas de aprobar"
  12. resultado = reprobo[nombre]
  13. if reprobo == {}:
  14. return False
  15. return resultado
  16. def agregar( lista, archivo):
  17. nuevo = open("a.txt","w",encoding="utf-8")
  18. contador = 0
  19. for datos in archivo:
  20. nuevo.write(datos)
  21. contador += 1
  22. if contador > 4:
  23. data = datos.strip().split( ":" )
  24. flag = True
  25.  
  26. if len(data) ==2 and flag == True:
  27. print( data )
  28. a = data[0]
  29. b = data[1]
  30. nuevo.write("{}:{}\n".format(a,b))
  31. flag = False
  32. else:
  33. nuevo.write( lista[0] )
  34. if len(lista) >1:
  35. nuevo.write("{}#{}:{}".format(lista[0],lista[1],lista[2]))
  36. elif len(lista) == 1:
  37. nuevo.write(lista[0])
  38. nuevo.close()
  39. return len(lista)
  40.  
  41.  
  42.  
  43.  
  44.  
  45. archivo = open( "C:\\Users\\HP\\OneDrive\\Escritorio\\Nueva carpeta (3)\\PyNote.txt","r")
  46. #print(reprobado("Eduardo Erick", archivo))
  47. print(agregar(["Alfonso Erick"], archivo))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement