2024-04-25 21:35:04 发布
网友
我做了这个函数,我想把它改成两个参数。一个是字母,一个是数字。函数应该打印适当数量的字母。(例如,如果用户键入“monkey”和“3”,函数将输出“mon”)
到目前为止这是我的密码
word = input ("What is your word?") number = input ("What is your number? ") def test(): letter=word[0] print (letter) test()
这就是你想要的吗?你知道吗
word = input("What is your word?") number = int(input("What is your number? ")) def test(word, number): print(word[:number]) test(word, number)
结果:
What is your word?monkey What is your number? 3 mon
word = input ("What is your word: ") number = input ("What is your number: ") def test(): print(word[:int(number)]) test()
这不应该给你你在朱利安·伯努的问题中提到的语法错误。你知道吗
注意:这是假设您使用的是最新版本的python
这就是你想要的吗?你知道吗
结果:
这不应该给你你在朱利安·伯努的问题中提到的语法错误。你知道吗
注意:这是假设您使用的是最新版本的python
相关问题 更多 >
编程相关推荐