【问题标题】:Inserting elements into a tuple at the time of running the code [closed]在运行代码时将元素插入元组[关闭]
【发布时间】:2019-08-19 12:18:32
【问题描述】:

在运行时输入 n 个整数。 n 个整数在一行中作为输入,以空格分隔。 我们必须创建一个包含这 n 个整数的元组并对其执行 hash(tuple) 函数并给出输出。

【问题讨论】:

  • 使用input()输入行。那会给你一个字符串。使用字符串方法split() 以空格分隔行。你会给你一个清单。调用tuple(mylist) 将列表变成一个元组。
  • Add Variables to Tuple的可能重复

标签: python python-3.x tuples


【解决方案1】:

这里是:

def your_homework():
    return hash(tuple([int(i) for i in input("give me n integers").split()]))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-17
    • 2012-09-06
    • 2021-10-26
    • 2020-08-12
    • 2015-11-25
    • 2017-11-06
    • 2011-12-24
    相关资源
    最近更新 更多