小编Kur*_*t_S的帖子

无论输入如何,Python函数都会运行到第一个if语句

我正在通过在线教程学习Python.我的问题是,当我运行脚本时,无论我输入什么响应,我得到的是if go =="kitchen"......

def go_to():
    go = raw_input("Go to? ")

    if go == Kitchen or breakfast:
         print "You rumble down stairs and into the kitchen. Your mom has left some microwaved waffles on the table for you. Your big boy step sits by the counter."
    elif go == "back to bed" or "back to sleep" or bed or sleep:
        print "You hit snooze and roll over."
    elif go == "bathroom" or "toilet" or "potty" or "pee" or "poop" or "take …
Run Code Online (Sandbox Code Playgroud)

python

3
推荐指数
1
解决办法
945
查看次数

ruby如何使用#capitalize!并保留字符串数字

所以我正在为ruby dev bootcamp做准备工作,并且需要创建一个可以大写标题的程序.我当前的代码使用#capitalize!但是当字符串中包含数字时,它被省略.

words = title.split(' ')
words.map! do |word|
  if %w(a aboard about above absent across after against along alongside amid amidst among amongst an and around as aslant astride at
    athwart atop barring before behind below beneath beside besides between beyond but by despite down during except for from in inside 
    into like mid minus near next nor notwithstanding of off on onto opposite or out outside over past per plus regarding round save 
    since so …
Run Code Online (Sandbox Code Playgroud)

ruby

-2
推荐指数
1
解决办法
38
查看次数

标签 统计

python ×1

ruby ×1