Python Forum
Questions on lists, the range function & concatenation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Questions on lists, the range function & concatenation
#1
Hi everyone.

2nd time poster so getting use to everything.

Here is what I got going on:
I am trying to create a list that looks like this:['a', 'b', 'c', ..., 'z'} so that I can then create a dictonary out of it.

I found a way to create that and the numbers 1-26

mport string
mylist = string.ascii_lowercase
a = "'"
b = "'"
c = ", "
for i in mylist:
    letters1 = a + i + b + c
    #print (letters1)

#Create range of numbers for merging
numbers = range(1,27)


But I am running into issues with the rest of the code I have which looks like this

#Create range of numbers for merging
numbers = range(1,27)
d = ":"
for n in numbers:
    numbers1 = str(n) + d
    print (numbers1)
I get an error when running the code and I can't seem to figure out how to get the numbers assigned to a list. If I just print numbers it says numbers = range (1,27) almost like it is treating it like a string instead of a function.

If I loop through I get an error about mistmatched types. If I loop through and try to convert those to a string (what is above) it also doesnt work.

If possible please explain this like you are talking to a 4 year old.

Thank you!
Reply


Messages In This Thread
Questions on lists, the range function & concatenation - by fad3r - Jan-24-2018, 03:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  function for extracting data from lists Paulman 9 2,890 Nov-09-2021, 04:00 PM
Last Post: Paulman
  How can I run a function inside a loop every 24 values of the loop iteration range? mcva 1 2,167 Sep-18-2019, 04:50 PM
Last Post: buran
  Recursive Function - Compare 2 lists, return the elements that don't exist in both KellyBaptist 1 5,277 Dec-23-2018, 10:10 AM
Last Post: Gribouillis
  Python Tutorial range function question HawkeyeKnight 2 2,744 Sep-27-2018, 09:45 AM
Last Post: ThiefOfTime

Forum Jump:

User Panel Messages

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