文件输入未终止

时间:2015-10-26 00:01:21

标签: python-2.7 user-input

我正在尝试在Spyder IDE中使用以下代码。

CTRL + D

当我尝试运行时,这是ipython控制台,它甚至没有响应。虽然如果我在python控制台中运行相同的操作,它会接受输入,但什么都不做,而不是通过>>> runfile('C:/Users.....) hello how are you

进行EOL
alert("ok");
var colors = ["black",
  "green",
  "yellow"
];
var alpha_colors = colors.sort();
var finished = false;
var guesses = 0;
var target = colors[Math.floor(Math.random() * alpha_colors.length)];

function do_game() {
  alert("ok so far");
  var color_guess = prompt("I am thinking of these colors \n\n" + alpha_colors + "What color am I thinking of?");
  guesses += 1;
  checkguess(color_guess);
}

function checkguess(color_guess) {
  if (color_guess == "stop") {
    return false;
  }
  if (colors.indexOf(color_guess) == -1) {
    alert("Sorry.  I don't recognize your color. \n\n Please try again");
    do_game();
  }
  if (color_guess < target) {
    alert("Sorry, your guess is not correct. \n\n Hint: your color is alphabetically lower than mine");
    do_game();
  }
  if (color_guess > target) {
    alert("Sorry, your guess is not correct. \n\n Hint: your color is alphabetically higher than mine");
    do_game();
  }
  if (colors.indexOf(color_guess) >= 0) {
    alert("Congratulations! You have guessed the color! \n\n It took you " + guesses + "guesses to finish the game! \n\n You can see the color in the background");
  }
  document.body.style.backgroundColor = target;
}

Stackoverflow没有在复制/粘贴上方显示有趣的字符。它就像一个小L向上/向下。

0 个答案:

没有答案