批评我的第一个python脚本,寻找建议

时间:2017-06-04 05:35:29

标签: python-3.5

在我的代码中查找所有错误,我很肯定有很多,我想知道是否有人可以指出它们并可能快速解释我如何解决它们。

forEach

1 个答案:

答案 0 :(得分:1)

我对此不太确定,你需要+运算符来连接变量

import time
import re

cls=("\n" * 50)

fname=input("Please enter your first name:: ")
lname=input("Please enter your last name:: ")

while True:
    age= str (input("Please enter your age:: "))
    if re.search('[0-9]', age):
        break

while True:

    print("Welcome to python "+fname," "+lname+", your current age is "+age)
    print(", This string should not break")

    addageyorn=input("Would you like to add X amount of years to your age, y or n:: ")

    if addageyorn==("y"):
        addage=input("How many years do you want to add to your age:: ")
        print("OK, so you want to add "+addage+" years to your current age of "+age)
        exeaddage = int(age) + int(addage)
        computed = str(exeaddage)
        print(", In "+addage+" years you will be ",computed," years old, thanks for signing in.")
        time.sleep(5)
        exit()

    if addageyorn==("n"):
        print("Thanks for signing in")
        time.sleep(5)
        exit()

    elif addageyorn!=("y", "n"):
        print("Invalid Input")