User Profile

Collapse

Profile Sidebar

Collapse
blackpaddycat
blackpaddycat
Last Activity: Jun 20 '14, 04:09 PM
Joined: Jun 19 '14
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • counting a collection of letters within a string

    Hi
    I am trying to write code that will return all instances of a collection of letters in a string variable...
    I can get a count returned, but it does not cater for letters that are used twice... for example

    Code:
    s = 'ajsfhbababnsnbabnndbab'
    n = s .count (str('bab'))
    print 'Number of times bab occurs is: ' + str(n)
    The code returns 3 instances but actually it is 4 - it is not...
    See more | Go to post

  • Ah, Thanks very much dwblas, and also for the reference to the style guide as well. V new to python, and indeed programming.
    Have now got the code working for 2.7 and 3.3.
    Feeling pleased rather than frustrated. Not very good at this programming malarky!
    See more | Go to post

    Leave a comment:


  • appending user entered items to array, then displaying them

    OK, so I am trying to make a shopping list which appends each item entered to an array until the user enters "0"
    I have got this far and it just doesnt work :-(
    Would really appreciate some suggestions or pointers!
    Thanks very much!

    Code:
    ShopList = [] 
    ListItem= ()
    print("To make a shopping list")
    print("Enter the items, when you have finished press 0 to display the list.")
    ...
    See more | Go to post
    Last edited by Rabbit; Jun 19 '14, 03:49 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
No activity results to display
Show More
Working...