Fibonacci sequence inconsistency -
I created a small program to generate the Fibonacci sequence in the user-defined length. At the moment when I run the code and input it like 6 digits, this sequence will display as follows:
1, 1,2,3,5,8,
How do the string Stays on one line, while I get rid of the initial space? Below is my code
#user intiger Input Print ("\ n") f = int (Input ("Enter the length of the sequence:")) Print ("\ n") f1 = 1 F2 = 1 multiply = 2 If F & lt; = 0: print ("Enter a positive integer for length") elif f == 1: print ("Fibonacci sequence:") print ("\ n") print (F1, end = ',') Other: Print ("Fibonacci sequence:") print (f1, ",", f2, end = ",") while multiplication and lt; F: f3 = f1 + f2 print (f3, end = ",") f1 = f2 f2 = f3 multiply + = 1 print ("\ n") < Print ("f1, end =", ") print (f2, end =", "div" = "post-text" itemprop = "text">
Other: print ("Fibonacci sequence:) < / Code> This is the easiest solution according to my perspective .. But seeing your code it seems that production should get rid of the initial spac, but try it according to the sensation; I know the output
Comments
Post a Comment