html, body {height:100%}
body {
background:rgb(255,243,230);
}
.page-container {
position: relative;
max-width:978px;
width: 100%;
min-height:100%;
background:rgb(240,240,240) url(http://www.waldorfteacherresources.com/img/lady-sprite.jpg) repeat top center;
}
.main-content {
max-width:808px;
width: auto;
margin-left:145px;
padding:0 9px 0 9px;
background: rgb(240,240,240);
overflow:visible !important;
}
.main-nav-vert {
display: block;
float:left;
width:145px;
overflow:visible;
}
这是针对问题3 here。我只是试图达到1000以包含数字def pingpong(n):
invisible_number = 0
return_value = 0
G = -1
while invisible_number != n:
if invisible_number > 10 and invisible_number < 100:
invisible_number_ones_digit = invisible_number % 10
invisible_number_tens_digit = invisible_number // 10
return invisible_number_ones_digit and invisible_number_tens_digit
if invisible_number > 100 and invisible_number < 1000:
invisible_number_ones_digit = (invisible_number % 10) % 10
invisible_number_tens_digit = (invisible_number % 10) // 10
invisible_number_hundreds_digit = (invisible_number // 10) // 10
return invisible_number_ones_digit and invisible_number_tens_digit and invisible_number_hundreds_digit
if invisible_number % 7 == 0:
return_value = return_value - G
G = -1 * G
elif invisible_number_ones_digit == 7 or invisible_number_tens_digit == 7 or invisible_number_hundreds_digit == 7:
return_value = return_value - G
G = -1 * G
else:
return_value += G
invisible_number += 1
return return_value
,因为我似乎无法找到我可以使用的模式。
答案 0 :(得分:0)
我假设你的UnboundLocalError是“赋值前引用的局部变量'invisible_number_ones_digit'”。你设置
invisible_number = 0
因此,如果您致电pingpong(n)
,其中n不是0,那么当您引用invisible_number_ones_digit
的值时,您的代码将会失败,您目前正在elif
进行操作。与您在为其分配值之前使用的任何其他变量相同。