2021年3月30日星期二

How to return a list on different lines in python?

Right now, my codes output is ['I love mac and cheese', ' cheese', 'se'], how would I change it so that the output would be a string and appear on different lines so "I love mac and cheese (first line) cheese (second line) se (third line) . This is the output when the user inputs .369 for fraction and I love mac and cheese for sentence

def echo(a,b, count):      newlen = int(len(b)*a)      if newlen > 0:          count+=1          return [b] + echo(a,b[-newlen:], count)      else:          count+=1          print("Number of echos: ", count)          return [b]            def main():      count=0      f=float(input("Enter the fraction"))      sentence=input("Enter the sentence")      print(echo(f,sentence, count))      main()        
https://stackoverflow.com/questions/66881359/how-to-return-a-list-on-different-lines-in-python March 31, 2021 at 11:45AM

没有评论:

发表评论