""" tuple trouble!!! if a truple only has one value it treats the values of that string individually you can add a comma after this value to rectify it or... """ one_t = ('bob') print one_t[0] two_t = ('bob',) print two_t[0] #solution use a list one_l = ['bob'] print one_l[0] #further searching reveals the problem #turn it into a list one_tl = ('bob') print type(one_tl) is tuple one_nl = list(one_tl) print type(one_nl) is list print one_nl[0] # Conclusion: #The commas are what makes a tuple. The empty tuple is the exception, not the rule.
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question