Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
strings that cycles
#1
a.     Generate a list of 10,000 strings that cycles through the lower case alphabet in a way similar to Excel’s column naming convention. For example, the sequence should look like: a,b,c,…,z, aa,ab,ac,…,az,ba,bb,bc,…,bz…etc.
Reply
#2
What have you tried?
Reply
#3
(Feb-09-2017, 09:26 PM)micseydel Wrote: What have you tried?


we are trying to use for and while loops when generating a list. But I don't have idea how to do it.
Reply
#4
Please show your code
Reply
#5
(Feb-12-2017, 10:17 PM)Larz60+ Wrote: Please show your code

list1 = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

while list1 > list1[25]:
    print list2 = ['a' + v for v in list1]
    list2 
    while list2 > list2[25]:
        list3 = ['b' + v for v in list1]
    list3
THIS GIVE US ERROR

this is what we have so far. we are new using python and were given with this assignment. thank you for replying
Reply
#6
Please use code or python tags. Please don't use formatting tags, especially in your code. And in the future, if you get an error, show us the full error so we know what it is.

You can't do an assignment in a print statement. You need to assign the value in one statement, then print it in another.

I don't understand you're while conditions at all. What are you expecting to get comparing the whole list to the last item in the list?

You want to loop until your list is 10,000 items long, and each loop you want to with the next item or items in that list.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#7
(Feb-12-2017, 10:26 PM)lizarragaman Wrote: THIS GIVE US ERROR

What error?

When you type while list1 > list1[25]:, what do you expect to happen?  Because comparing a list to an element of that list is a meaningless comparison, and the best case scenario is that it is always False.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Cycles homework Roman_Y 3 1,950 Sep-09-2021, 01:53 PM
Last Post: Roman_Y
  Strings inside other strings - substrings OmarSinno 2 3,622 Oct-06-2017, 09:58 AM
Last Post: gruntfutuk

Forum Jump:

User Panel Messages

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