473,394 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

'int' object not iterable

Expand|Select|Wrap|Line Numbers
  1. def string_count(y):
  2.     count = 0
  3.     for a in y:
  4.      if(a=="ram"):
  5.        count=count+1
  6.        print count
  7.     else:
  8.       print "zero"
  9.  
  10.     x = ["sizz" ,"vixx", "dfd" ,"ram","furram","ram"]
  11.  
  12. string_count(x)
  13.  
Jun 20 '14 #1
2 1744
dwblas
626 Expert 512MB
You should get an error on the
string_count(x)
line saying that x is not defined because x is inside the function in the code you posted and therefore local to the function only. There is no error "'int' object not iterable" and you have not posted the complete error message so we have no way of knowing what the problem is.
Jun 20 '14 #2
Just move definition of x before calling string_count function.
Jun 20 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

100
by: E. Robert Tisdale | last post by:
What is an object? Where did this term come from? Does it have any relation to the objects in "object oriented programming"?
13
by: Mike S | last post by:
I came across the following paragraph in the "Semantics" section for simple assignment in N1124 (C99 draft) and I'm wondering if I'm interpreting it right: 6.5.16.1p3: If the value being...
37
by: sid | last post by:
hi , whats the issue with the following declaration, is it correct and what exactly is happening here. int main() { //..... int* ptr=10; // i suppose ptr is pointing to the memory...
2
by: AWasilenko | last post by:
I'm trying to test a few different approaches to displaying pages via Cherrypy and I'm not having much luck. Here is my code so far: import sys, cherrypy, html class Root: @cherrypy.expose...
0
by: king kikapu | last post by:
Hi, i have a problem with the following piece of code that id just drive me nuts (from the morning...) I think is more Python specific than Qt, folks from Qt forum have already give me...
19
by: python101 | last post by:
I try to calculate the sum of an infinite series S = Sum (from n=0 to 100) 1/k! I got message 'float' / 'int' object is not iterable. How can I fix this?
2
by: mmiikkee13 | last post by:
>>a_list = range(37) .... print k, v .... Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'int' object is not iterable What 'int' object is this...
5
by: cj007541 | last post by:
Hey. Im working on this for a school project thing and i need some help please. from Tkinter import* import random import time number = 5 i = 0
4
by: arturo trafny | last post by:
I am getting the following error: ##this is the error message i receive Traceback (most recent call last): File "C:\Users\a\Desktop\checkerboard", line 26, in <module> ...
1
by: dillonko | last post by:
def remove_duplicates(xlist): new_list = return print remove_duplicates() i am trying to remove repeating numbers from a list that can be any size. but when I test out this idea i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.