Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tuple
#2
tuple("veysel",) is same as tuple("veysel"). When you pass str as argument to tuple() function it returns tuple of chars:

>>> tuple("veysel")
('v', 'e', 'y', 's', 'e', 'l')
>>>
effectively first snippet is
s=("hello",)
b=s+('v', 'e', 'y', 's', 'e', 'l')
print(b)
In the second example, both s and a are tuples. Note that a is tuple, because of the comma at the end:
>>> a = 'veysel',
>>> type(a)
<class 'tuple'>
>>>
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
tuple - by veysel - Feb-21-2019, 09:12 AM
RE: tuple - by buran - Feb-21-2019, 09:43 AM
RE: tuple - by veysel - Feb-21-2019, 10:05 AM
RE: tuple - by buran - Feb-21-2019, 10:12 AM
RE: tuple - by veysel - Feb-21-2019, 10:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  code with no tuple gets : IndexError: tuple index out of range Aggam 4 2,891 Nov-04-2020, 11:26 AM
Last Post: Aggam
  How to get first line of a tuple and the third item in its tuple. Need Help, Anybody? SukhmeetSingh 5 3,290 May-21-2019, 11:39 AM
Last Post: avorane

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020