尝试在Python中读取用户输入时出现NameError

时间:2017-06-05 19:43:03

标签: python input nameerror

HY!我正在创建一个计算概率的软件。 我的问题是,当我想问我们在谈论什么样的项目并且我写它时,我会遇到语法错误。

# -*- coding: utf-8 -*-
from __future__ import division
from scipy.stats import hypergeom
import matplotlib.pyplot as plt
from operator import itemgetter
from random import randint
import scipy.special
import math
import random
from scipy.stats import binom

object = str(input("What kind of items are we talking about?"))
population = int(input("How many " + object + "do we have?"))

错误:

    What kind of items are we talking about?car
Traceback (most recent call last):
  File "/Users/suhajdakrisztian/PycharmProjects/firsttrial/input.nemtudomanevet.py", line 12, in <module>
    object = str(input("What kind of items are we talking about?"))
  File "<string>", line 1, in <module>
NameError: name 'car' is not defined

Process finished with exit code 1

0 个答案:

没有答案