# 求問一道Python新手題目

**URL:** <https://forum.freemdict.com/t/topic/19509>\
**Category:** 技术交流与词典编修\
**Tags:** 求助\
**Created:** [2023 年3 月 5 日 12:18 UTC](https://forum.freemdict.com/t/topic/19509 "2023-03-05T12:18:12Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

作者： ![eudic](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/e/77aa72/32.png) [@eudic](https://forum.freemdict.com/u/eudic)\
发布日期： [2023 年3 月 5 日 12:18 UTC](https://forum.freemdict.com/t/topic/19509/1 "2023-03-05T12:18:12Z")

</div>

items=list(reversed(range(12)))  
items[::3]=range(12,0,-3)  
print(items)  
用IDE得出了結果，是[12, 10, 9, 9, 7, 6, 6, 4, 3, 3, 1, 0]，但是看不懂為什麼呀 😂 求大神解答

PS.不知道這個帖子可以分類到哪裡，如果歸類錯了求指正

---

<div class="post-metadata">

作者： ![mdict6](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/m/8491ac/32.png) [@mdict6](https://forum.freemdict.com/u/mdict6)\
发布日期： [2023 年3 月 5 日 12:21 UTC](https://forum.freemdict.com/t/topic/19509/2 "2023-03-05T12:21:10Z")

</div>

这个问题是不是考虑问 chatgpt 可解？

---

<div class="post-metadata">

作者： ![mdict6](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/m/8491ac/32.png) [@mdict6](https://forum.freemdict.com/u/mdict6)\
发布日期： [2023 年3 月 5 日 12:30 UTC](https://forum.freemdict.com/t/topic/19509/3 "2023-03-05T12:30:14Z")

</div>

贴一下我整理的 chatgpt 关于客户端的笔记：

mac app

> **[OpenCat - Chat with AI bot App - App Store](https://apps.apple.com/us/app/opencat-chat-with-ai-bot/id6445999201)**
>
> Download OpenCat - Chat with AI bot by Early Moon, LLC on the App Store. See screenshots, ratings and reviews, user tips, and more apps like OpenCat - Chat with…

iOS app (ios16+)  
TestFlight

> **[TestFlight - Apple](https://testflight.apple.com/join/cSlRb0J2)**
>
> 使用 TestFlight 是帮助开发者测试 Beta 版 App 的理想方式。

# 为什么用app ？

开发者说，

> 受不了每次打开 ChatGPT 都要先“验证你是人类”然后等半天才能用，就做了一个原生桌面客户端，随时随地都能响应。注意使用这个 App 需要你有自己的 ChatGPT 账号， 生成个 API key 就能用了，你也可以将自己的 key 分享给家人使用。iOS、iPadOS 版本马上就好。

限制：

1. [自己有openai.com](http://xn--openai-hy0ly41dm70d.com) 账号
2. 申请免费api（就是去官网点一下）
3. 免费api月度限制5000。即、日均不超过166条 （第三点我群里看来的，没验证）
4. 开代理

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2023 年3 月 5 日 12:40 UTC](https://forum.freemdict.com/t/topic/19509/5 "2023-03-05T12:40:28Z")

</div>

在Python的解释器里，自己打印下就能看到每行结果了：

```auto
>>> print(*list(reversed(range(12))))
11 10 9 8 7 6 5 4 3 2 1 0
>>> print(*items[::3])
11 8 5 2
>>> print(*range(12,0,-3))
12 9 6 3

```

如果还不理解，需要再翻翻对应函数的文档。

PS：初学编程，推荐去小甲鱼的论坛，那边学Python的人多，对新手很友好。

---

<div class="post-metadata">

作者： ![eudic](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/e/77aa72/32.png) [@eudic](https://forum.freemdict.com/u/eudic)\
发布日期： [2023 年3 月 5 日 12:42 UTC](https://forum.freemdict.com/t/topic/19509/6 "2023-03-05T12:42:55Z")

</div>

但是還是看不懂[12, 10, 9, 9, 7, 6, 6, 4, 3, 3, 1, 0]是哪裡來的 😭  
小甲魚是什麼呀，我下載了CSDN，但是問答不能問作業，不過很好用幫助我很多

---

<div class="post-metadata">

作者： ![atauzki](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/atauzki/32/1365_2.png) [@atauzki](https://forum.freemdict.com/u/atauzki)\
发布日期： [2023 年3 月 5 日 12:44 UTC](https://forum.freemdict.com/t/topic/19509/7 "2023-03-05T12:44:26Z")

</div>

列表里面原来的元素替换了啊

---

<div class="post-metadata">

作者： ![eudic](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/e/77aa72/32.png) [@eudic](https://forum.freemdict.com/u/eudic)\
发布日期： [2023 年3 月 5 日 12:49 UTC](https://forum.freemdict.com/t/topic/19509/8 "2023-03-05T12:49:45Z")

</div>

謝謝你，我太傻了 🤣 都沒有意識到需要替換

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2023 年3 月 5 日 12:50 UTC](https://forum.freemdict.com/t/topic/19509/9 "2023-03-05T12:50:00Z")

</div>

> **[鱼C-小甲鱼的个人空间-鱼C-小甲鱼个人主页-哔哩哔哩视频](https://space.bilibili.com/314076440)**
>
> 哔哩哔哩鱼C-小甲鱼的个人空间，提供鱼C-小甲鱼分享的视频、音频、文章、动态、收藏等内容，关注鱼C-小甲鱼账号，第一时间了解UP注动态。带你自学编程带你飞Σ(▼□▼メ)
> 背后是#鱼C论坛 百万鱼油兄弟姐妹们的支持

[https://fishc.com.cn/forum-173-1.html](https://fishc.com.cn/forum-173-1.html)

---

<div class="post-metadata">

作者： ![eudic](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/e/77aa72/32.png) [@eudic](https://forum.freemdict.com/u/eudic)\
发布日期： [2023 年3 月 5 日 12:51 UTC](https://forum.freemdict.com/t/topic/19509/10 "2023-03-05T12:51:35Z")

</div>

好的，謝謝你！！

---

<div class="post-metadata">

作者： ![匿名1417](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/%E5%8C%BF/8797f3/32.png) [@匿名1417](https://forum.freemdict.com/u/%E5%8C%BF%E5%90%8D1417)\
发布日期： [2023 年3 月 5 日 14:21 UTC](https://forum.freemdict.com/t/topic/19509/11 "2023-03-05T14:21:26Z")

</div>

> [@mdict6](#):
>
> 这个问题是不是考虑问 chatgpt 可解？

ChatGPT 给出了正确的解释 & 错误的结果

Python Code: items = list(reversed(range(12))) items[::3] = range(12, 0, -3) tell me the resulting value of the ‘items’ list and explain

> **Answer from ChatGPT**
>
> The resulting value of the 'items' list after executing the given code will be [9, 6, 3, 12, 10, 7, 4, 1, 11, 8, 5, 2].  
>   
> Explanation:  
>   
> Here's the step by step explanation of the given code:  
>   
> \* The 'reversed' function is applied to the range between 0 and 12 (exclusive), which returns the reversed order of integers from 11 to 0. So, the 'items' list will be [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0].  
>   
> \* The slicing operation [::3] selects every 3rd element in the 'items' list starting from the first element. Thus, it selects [11, 8, 5, 2] from the list.  
>   
> \* The right-hand side of the assignment, which is range(12, 0, -3), creates a new list of integers starting from 12 and decrementing by 3 until 0 (exclusive). So, it generates [12, 9, 6, 3] in reverse order.  
>   
> \* Finally, the selected list [11, 8, 5, 2] is replaced with the new list [12, 9, 6, 3] using the assignment statement. Thus, the resulting value of the 'items' list is [9, 6, 3, 12, 10, 7, 4, 1, 11, 8, 5, 2].
