如何以简单的方式区分输入中的数字?

2024-04-25 17:06:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我现在正在学习如何使我的程序在一个函数中区分两种类型的输入。。。我知道这是可能的,但我如何才能真正做到这一点;-; 以下是我的一些代码:

def alphanumeric_input_detection(base_input):
    if (type(base_input)==str):
        return (print("you've written it wrong you dumm dumm"))
    else:
        return(print("thats correct input"))

base_input=input("please write a number")

alphanumeric_input_detection(base_input)

Tags: 函数代码程序you类型inputbasereturn