-5 python python-3.x
Word1 = input("Please type a word: ")
Word2 = input("Please type a word: ")
if len(Word1) + len(Word2)> 30:
print("Words are to long")
# exit -- Gotten rid of.
30 - (len(Word1) + len(Word2) == DotAmount
print (Word1 + "."*DotAmount + Word2) # This line is causing the problem
Run Code Online (Sandbox Code Playgroud)
我似乎无法解决这个问题.有人想帮忙吗?
编辑:该程序要求用户输入2个单词,然后在它们之间打印带点符号(.),以便打印30个字符.如果有人有更好的方法来编写这个程序,请随意添加它.通过CMD打开错误是
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)
指针指向打印.
我假设您要分配值
30 - (len(Word1) + len(Word2)) ## note that you were also missing a closing paren
Run Code Online (Sandbox Code Playgroud)
这个名字DotAmount.
执行此操作的python语法是
name = value
Run Code Online (Sandbox Code Playgroud)
所以你要
DotAmount = 30 - (len(Word1) + len(Word2))
Run Code Online (Sandbox Code Playgroud)
有关信息,请a == b检查是否a等于b和返回,True或者False在这种情况下被丢弃.