SHARE
TWEET

asd

a guest Feb 14th, 2020 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class nodos:
  2.     def __init__(self, data=None):
  3.         self.data = data
  4.         self._p = None
  5.  
  6.     def __str__(self):
  7.             d=self.data+","+str(self._p)
  8.             return d
  9.  
  10. """
  11.        def getdata(self):
  12.            return self.data
  13.  
  14.        def getvacio(): #<--- metodo "vacio retorna verdadero si el primer elemento es nada"
  15.            if self.data == None:
  16.                return True
  17. """
  18.  
  19.        
  20.        
  21. def agg (p):
  22.     if (p.data == None):
  23.  
  24.         p.data=(int(input("ingrese dato: ")))
  25.         p._p=None
  26.     else:
  27.         y=nodos()
  28.         y.data=(int(input("ingrese dat2o: ")))
  29.         p._p = y
  30.     return p
  31.        
  32.     return(p)
  33. def imprimir(p):
  34.     print(p.data)
  35.     print("hola")
  36.     x=p
  37.     while x._p!=None:
  38.         print (x.data)
  39.         x=x._p  
  40.  
  41. p=nodos()
  42. for a in range(2):
  43.     p=agg(p)
  44. imprimir(p)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top