小编Kil*_*Bio的帖子

Python:另一个函数从一个函数访问返回的值

我是一般编程的新手,刚开始真正接触python。我正在做一个数字猜测项目。

import random

def main(): # main function
    print("Welcome to the number guesser game")
    range_func()
    max_guess_number(lower_range_cut, upper_range_cut)
    evaluation(random_number, total_guesses)

def range_func():   # allows user to select a range for the number guess
    print("Please select a range in which you would like to guess.")
    lower_range_cut = int(input("Lower boundary limit: "))
    global lower_range_cut
    upper_range_cut = int(input("Upper boundary limit: "))
    global upper_range_cut
    random_number = random.randint(lower_range_cut,upper_range_cut)
    global random_number
    return lower_range_cut, upper_range_cut, random_number

def max_guess_number(low,high): # returns the total number of guesses
    total_numbers = (high …
Run Code Online (Sandbox Code Playgroud)

python return function access

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

access ×1

function ×1

python ×1

return ×1