Write a function store_digits that takes in an integer n and returns a linked list where each element of the list is a digit of n.



Answer :

def store_digits(n):

   """Stores the digits of a positive number n in a linked list.

   >>> s = store_digits(1)

   >>> s

   Link(1)

   >>> store_digits(2345)

   Link(2, Link(3, Link(4, Link(5))))

   >>> store_digits(876)

   Link(8, Link(7, Link(6)))

   """

   "*** YOUR CODE HERE ***"

   1 = Link.empty

   while n > 0:

       1 = Link(n % 10, 1)

       n //= 10

   return 1

Store Digits

In some programming languages you have to declare a variable before using them or define the information that will be stored in it, e.g., a number. However, in Python we just need to type the name of our variable, followed by an equals sign and a value to assign to it.

To learn more about Python visit:

brainly.com/question/13702416

#SPJ4