René's URL Explorer Experiment


Title: random.choice input 3 args but error msg say 4 args given · Issue #3 · softnshare/python · GitHub

Open Graph Title: random.choice input 3 args but error msg say 4 args given · Issue #3 · softnshare/python

X Title: random.choice input 3 args but error msg say 4 args given · Issue #3 · softnshare/python

Description: Question 我在工作上是用 ruby,這幾天開始學python,有個狀況不太懂,想跟大家請教一下 想請問為什麼它說我給了4個 arguments?? 我看起來只給了3個args 事情是這樣的,我的 random.choice 寫錯了 但 error msg 的內容讓我很好奇,如下: # 錯誤寫法 >>> random.choice(1,2,3) Traceback (most recent call last): File "", line 1, i...

Open Graph Description: Question 我在工作上是用 ruby,這幾天開始學python,有個狀況不太懂,想跟大家請教一下 想請問為什麼它說我給了4個 arguments?? 我看起來只給了3個args 事情是這樣的,我的 random.choice 寫錯了 但 error msg 的內容讓我很好奇,如下: # 錯誤寫法 >>> random.choice(1,2,3) Traceback (most rece...

X Description: Question 我在工作上是用 ruby,這幾天開始學python,有個狀況不太懂,想跟大家請教一下 想請問為什麼它說我給了4個 arguments?? 我看起來只給了3個args 事情是這樣的,我的 random.choice 寫錯了 但 error msg 的內容讓我很好奇,如下: # 錯誤寫法 >>> random.choice(1,2,3) Traceback (...

Opengraph URL: https://github.com/softnshare/python/issues/3

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"random.choice input 3 args but error msg say 4 args given","articleBody":"## Question\n\n我在工作上是用 ruby,這幾天開始學python,有個狀況不太懂,想跟大家請教一下\n想請問為什麼它說我給了4個 arguments??  我看起來只給了3個args\n\n事情是這樣的,我的 random.choice 寫錯了\n但 error msg 的內容讓我很好奇,如下: \n\n```\n# 錯誤寫法\n\u003e\u003e\u003e random.choice(1,2,3)\nTraceback (most recent call last):\n  File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\nTypeError: choice() takes exactly 2 arguments (4 given)\n```\n\n我給了3個 arguments,error msg 卻說 4 given,why~?!!!\n## Answers\n\n@raytong \nrandom.choice 應該是 def choice(self, array), 所以比你原來的多了一個 argument\nhttp://openhome.cc/Gossip/Python/Class.html\n\n@d2207197 \nrandom 是 Random class 的 instance。所有 instance method 第一個參數是 self,會自動給。\n建議用 ipython 來當 REPL 不要用 python,會好用很多。\n在 ipython 上可用 `?` 與 `??` 來查文件。以你的例子就是\n`import random\nradom.choice??`\n另外有 browser 的話可以用 jupyter notebook ,開發和測試。自己電腦懶得裝可以先到 https://tmpnb.org 玩\n## 結論\n\n原因在於 choice 的定義大概是像這樣\ndef deposit(self, array):\n也是為什麼它只接受一個array,卻表示 choice() takes exactly 2 arguments\n因為第一個 arg 是 self,會自動賦予\n\n正確寫法\n\n``` python\n*正確寫法*\n\n random.choice([1,2,3])\n2\n```\n\n要加入Slack Python討論channe請參考[入口網頁](https://softnshare.wordpress.com/slack/python/)\n","author":{"url":"https://github.com/jcsky","@type":"Person","name":"jcsky"},"datePublished":"2016-06-16T03:23:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/3/python/issues/3"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:46471407-7a67-2320-156a-1752ffd63f91
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB67E:D45B7:2A596F:3990BE:698F254F
html-safe-noncebea6ad5cc0f5be4dcd7c7590e62c2aae37484c9836dfb6fb34ddc2f41cd015a3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjdFOkQ0NUI3OjJBNTk2RjozOTkwQkU6Njk4RjI1NEYiLCJ2aXNpdG9yX2lkIjoiNTE4NzE0OTU5NzA1OTc4NjA2MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac47339094b14f15334827de78a1da00d5f2a4e180e3c20f7cf015d2bdf4acc0db
hovercard-subject-tagissue:160569667
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/softnshare/python/3/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a85f3e0d212e48ffe4aaa25900543b41684a5f9de13262826c897e172b92b267/softnshare/python/issues/3
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a85f3e0d212e48ffe4aaa25900543b41684a5f9de13262826c897e172b92b267/softnshare/python/issues/3
og:image:altQuestion 我在工作上是用 ruby,這幾天開始學python,有個狀況不太懂,想跟大家請教一下 想請問為什麼它說我給了4個 arguments?? 我看起來只給了3個args 事情是這樣的,我的 random.choice 寫錯了 但 error msg 的內容讓我很好奇,如下: # 錯誤寫法 >>> random.choice(1,2,3) Traceback (most rece...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejcsky
hostnamegithub.com
expected-hostnamegithub.com
None6102991c714c1a6a27d05fb4f96ea6ca87a6750b4f093b95cc57ed1b84b145a1
turbo-cache-controlno-preview
go-importgithub.com/softnshare/python git https://github.com/softnshare/python.git
octolytics-dimension-user_id18457860
octolytics-dimension-user_loginsoftnshare
octolytics-dimension-repository_id59437234
octolytics-dimension-repository_nwosoftnshare/python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id59437234
octolytics-dimension-repository_network_root_nwosoftnshare/python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
released52a41ad9b9ffb9b63a1b4a600a6054be8b70b36
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/softnshare/python/issues/3#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsoftnshare%2Fpython%2Fissues%2F3
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsoftnshare%2Fpython%2Fissues%2F3
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=softnshare%2Fpython
Reloadhttps://patch-diff.githubusercontent.com/softnshare/python/issues/3
Reloadhttps://patch-diff.githubusercontent.com/softnshare/python/issues/3
Reloadhttps://patch-diff.githubusercontent.com/softnshare/python/issues/3
softnshare https://patch-diff.githubusercontent.com/softnshare
pythonhttps://patch-diff.githubusercontent.com/softnshare/python
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fsoftnshare%2Fpython
Fork 0 https://patch-diff.githubusercontent.com/login?return_to=%2Fsoftnshare%2Fpython
Star 3 https://patch-diff.githubusercontent.com/login?return_to=%2Fsoftnshare%2Fpython
Code https://patch-diff.githubusercontent.com/softnshare/python
Issues 4 https://patch-diff.githubusercontent.com/softnshare/python/issues
Pull requests 0 https://patch-diff.githubusercontent.com/softnshare/python/pulls
Actions https://patch-diff.githubusercontent.com/softnshare/python/actions
Projects 0 https://patch-diff.githubusercontent.com/softnshare/python/projects
Security 0 https://patch-diff.githubusercontent.com/softnshare/python/security
Insights https://patch-diff.githubusercontent.com/softnshare/python/pulse
Code https://patch-diff.githubusercontent.com/softnshare/python
Issues https://patch-diff.githubusercontent.com/softnshare/python/issues
Pull requests https://patch-diff.githubusercontent.com/softnshare/python/pulls
Actions https://patch-diff.githubusercontent.com/softnshare/python/actions
Projects https://patch-diff.githubusercontent.com/softnshare/python/projects
Security https://patch-diff.githubusercontent.com/softnshare/python/security
Insights https://patch-diff.githubusercontent.com/softnshare/python/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/softnshare/python/issues/3
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/softnshare/python/issues/3
random.choice input 3 args but error msg say 4 args givenhttps://patch-diff.githubusercontent.com/softnshare/python/issues/3#top
技術問答https://github.com/softnshare/python/issues?q=state%3Aopen%20label%3A%22%E6%8A%80%E8%A1%93%E5%95%8F%E7%AD%94%22
https://github.com/jcsky
https://github.com/jcsky
jcskyhttps://github.com/jcsky
on Jun 16, 2016https://github.com/softnshare/python/issues/3#issue-160569667
@raytonghttps://github.com/raytong
http://openhome.cc/Gossip/Python/Class.htmlhttp://openhome.cc/Gossip/Python/Class.html
@d2207197https://github.com/d2207197
https://tmpnb.orghttps://tmpnb.org
入口網頁https://softnshare.wordpress.com/slack/python/
技術問答https://github.com/softnshare/python/issues?q=state%3Aopen%20label%3A%22%E6%8A%80%E8%A1%93%E5%95%8F%E7%AD%94%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.