首页 > 解决方案 > How to measure how many lines are in a user-inputed string in python

问题描述

I am trying to get the user to input a string, I then want to count the number of lines they have inputted and save it in a variable to use in a for loop. so far I have tried this:

asciiart = input("Please enter your entire ASCII art: ")
nlines = len(asciiart.split('\n'))
print(nlines)

标签: pythonstringline

解决方案


推荐阅读