看板 Python 關於我們 聯絡資訊
※ 引述《tiger66 (虎虎)》之銘言: : 請問各位大神,我最近是用2x版本的書在學習, : 用的是3.x的版本。 : 這個問題我試了非常多次搞不懂,才上來問。 : 我想要出現的結果是 : ***** : ***** : ***** : 但是一直呈現下面這樣,而且還出現built-in function print, : 請問要怎麼去掉呢?謝謝。 : numlines = int(input('how many lines do you want?'))3 : numstars = int(input('how many stars do you want?'))5 : for line in range (0, numlines): : for star in range(0, numstars): : print('*',) : print for line in range(numlines): print(“*” * numstars) The reason for the last <built-in function print> Was because you called “print” without (), which is a function itself. Then you need to remember that print function automatically appends a newline for you. Good luck~~ : * : * : * : * : * : <built-in function print> : * : * : * : * : * : * : <built-in function print> : * : * : * : * : * : <built-in function print> -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 67.160.193.120 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1508819627.A.4CB.html