[split] help me make this code better please (basic) - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: [split] help me make this code better please (basic) (/thread-27740.html) |
[split] help me make this code better please (basic) - Rustam - Jun-19-2020 I'm just study Python and fall in very stupid situation This code every time have different results, looks like if range() returns random result in range: l = {str(i)+str(i-1) for i in range(20)} print(l)
RE: [split] help me make this code better please (basic) - buran - Jun-19-2020 what you create is set (i.e. that is because you use curly braces { and }). sets are unordered. That's why the elements are the same, but order in which they are print is different.use brackets [ and ] to create list or ( and ) to create tuple. Also don't use names like l , o - they are discouraged because it's easy to confuse with 1 and 0
RE: [split] help me make this code better please (basic) - Rustam - Jun-19-2020 (Jun-19-2020, 12:00 PM)buran Wrote: what you create is Thanks, I will consider your comments for the future |