string - Cl0sed Functions in Druid -
I am trying to write a function that takes an 8-character binary string and as an integer n A positive number, and N prints the sequence of binary numbers which increases according to my incremental function.
How can I edit my work so that I can print them?
Assume that all your other codes are correct, there are five problems in your recursive code.
First of all, you are trying to use the value returned by the recurring call on Forward, You are trying to increase the After this, you are trying to call yourself with Next, you are Finally, you want to clearly print the original value and the next 4, not the next 5 original value, then you have to print the pre-incremented value, not later in growth. Then, there is a minimum change in your code: count . But you do not have any
return statement, so what might this possibly be? So try to multiply a string by
inc * cnt just
any and raise a
typeError . If you see your code, you do not need to back anything upside down;
Count just takes something, prints something, and again calls itself, do not ignore
any
s [-1] . But
s is a string, so it's going to be just the last character you want to "increase" the entire string, right? Just pass
s .
s [: - 1] . Then,
s is a string; This will try to increase the first 7 digits of that string, then the first 6, and so on. Why would you want that? The amount you want to increase is your increased value is this is the same thing that you store in
inc just enter
inc Pass.
print after with a recursive call. This means that you are going to call the function that prints the second and the subsequent values, then print the first value. And so on. Therefore they will appear in reverse order. If you want to first value the first,
print before the recursive call.
def count (s), n): if n == 0: return: inc = increment (s) ) Number (inc, n-1)
Comments
Post a Comment