如何检查重复的数字并将其添加到自己的列表中

时间:2019-06-26 17:00:37

标签: python python-3.x list variables

我正在尝试有两个数组,一个数组保存的数字大于10,另一个数组保存在第一个列表中重复的数字。

例如:

如果lisps具有[28,24,15,20,11,17,20,12,12,15]

lisps_重复将保留[12,20,15]

我不确定如何检查重复。

    from random import randint

    lisps = list()
    hold = list()
    lisps_repeat = list()


    while len(lisps) < 10:
        rand = randint(0,30)
        if rand > 10:
            lisps.append(rand)
            print(f'{rand} Greater than 10')
        elif rand < 10:
            print(f'{rand} less than 10')

    print(lisps)


    for k in lisps:
        for i in range(0, 10):
            if k == lisps[-1]:
               lisps = lisps.pop()
               lisps_repeat.append(k)
               print(f'{k} Already included')




     print(lisps_repeat) 

6 less than 10
15 Greater than 10
20 Greater than 10
7 less than 10
13 Greater than 10
20 Greater than 10
30 Greater than 10

1 个答案:

答案 0 :(得分:1)

您可以使用[15, 20, 12] doc)来完成任务:

  methods: {
    showBinaries(job, id) {
      let test_url = process.env.VUE_APP_TEST_APP + "/api/v1/job=this.job&id=this.id"
      // how do i access job and build_id correctly here?
    }
  }

打印:

  <template v-for='job in new_jobs'>
    <span @click='showBinaries(job.name, job.id)'><li>job id is: {{ job.id }}</li></span>
    <ul v-if="showIosMasterBinaries===job.id">
      <li>test 1</li>
      <li>test 2</li>
    </ul>
  </template>