473,609 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'int' object not iterable

1 New Member
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 1747
dwblas
626 Recognized Expert Contributor
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
invention
10 New Member
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
5220
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
3153
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 stored in an object is read from another object that overlaps in any way the storage of the first object, then the overlap shall be exact and the two objects shall
37
498
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 location which
2
6711
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 def index(self, pageid = None): selection = html.Page() return selection.input()
0
1396
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 directions of how to do it but that Python error message is just impossible for me to figure out. And i am sure that it something just under my nose... So, i have a form with 2 spin boxes, a button and a progress bar. When
19
23830
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
10985
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 referring to? I'm iterating over a dict, not an int.
5
9815
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
4073
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> print(checkerboard(plaintext)) File "C:\Users\a\Desktop\checkerboard", line 20, in checkerboard ciphertext=ciphertext+idx TypeError: Can't convert 'int' object to str implicitly
1
11534
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 hit a brick wall. I get TypeError: 'int' object is not iterable. I have tried several alternatives as a single liner but was unsuccessful. Please can somone help me.
0
8126
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8065
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8524
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8210
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5507
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2527
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.