我正在介绍使用 zyBooks 的编程课程,所以我不确定(由于这个解释器的工作方式)我的问题是我做了一些愚蠢的事情还是只是无法正常使用 zyBooks。
它要求我做一个基本的用户输入字符串。这些是说明:
为 user_str 分配来自用户输入的字符串,提示:'输入字符串:'
提示 - 替换 ? 在以下代码中: user_str = ?('Enter a string: ')
我相信我已经按照它给我的说明做了,但我收到了这个错误。谢谢你的帮助!!!
1
2 '''Your Solution Goes here '''
3 user_str = int(input'Enter a string: '))
4 print()
5
6 print(user_str)
我得到的错误:
Exited with return code 1
Traceback (most recent call last):
File "main.py", line 3, in <module>
user_str = int(input('Enter a string: '))
ValueError: invalid literal for int() with base 10: 'Hello!'
你不能把Hello!
成int
。摆脱int(...)
周围的输入。
注意:如果字符串是有效数字,您可以将字符串转换为整数。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句