python - 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)
解决方案
推荐阅读
- flutter - SingleChildScrollView + Column:溢出或忽略 mainAxisAlignment
- aws-lambda - 使用服务的多种方法从另一个 Lambda 调用 AWS Lambda 函数,而无需任何条件参数
- r - R脚本的期望与输出不匹配
- javascript - 显示从 redux 成功发布数据的模式
- node.js - Vue 数据属性中的敏感数据
- api - 如何保护nestjs swagger端点
- google-oauth - GoogleCredential 弃用
- html - Datepicker 在 IOS14 beta 5 上消失了,包括图标,但在 iPad Pro 的较低版本中工作正常
- snowflake-cloud-data-platform - 外部表雪花刷新问题/问题/确认/在 azure 平台上使用外部阶段
- microsoft-graph-api - Microsoft Graph 统一联系人列表