2021年2月3日星期三

Trying to convert pseudo code into Python code

I have a pseudocode that I need to turn into functional Python code and see what it prints.

I am having problem understanding how to convert certain parts. n has to be an number like 7 for exampel.

Any help would be appreciated.

Thanks,

PrintThis(n)         for i=1 to n             str = " " //empty string             for j=1 to i                 str = str+"x"             print (str)  

This is what I got:

def PrintShape(n):      for i in n:          str = " "          for j in i:              str = str + "x"          print(str)  
https://stackoverflow.com/questions/66038819/trying-to-convert-pseudo-code-into-python-code February 04, 2021 at 11:04AM

没有评论:

发表评论