473,671 Members | 2,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can only concatenate list (not "str") to list

1 New Member
My program is supposed to reverse the string inputted, print it then extract the numbers and print the numbers of the reversed string in a list.

Expand|Select|Wrap|Line Numbers
  1. def reverse_str(string):
  2.     revstring =('')
  3.     length=len(string)
  4.     i = length - 1
  5.     while i>=0:
  6.         revstring = revstring + string[i]
  7.         i = i - 1
  8.     return revstring
  9. def strip_digits(string):
  10.     result = []
  11.     for c in string:
  12.         result = result + c
  13. string = raw_input("Enter a string->")
  14. new_str = reverse_str(string)
  15. print new_str
  16. numberless_str  = strip_digits(string)
Oct 16 '12 #1
2 5446
Rabbit
12,516 Recognized Expert Moderator MVP
Please use code tags when posting code.

You've told us what you want to do. Now what's your question?
Oct 16 '12 #2
dwblas
626 Recognized Expert Contributor
can only concatenate list (not "str") to list
You should have included the complete error message which includes the offending line.

"+" concatenates 2 lists. To add another string to an existing list use append (see "list methods"). Note also that you pass "string" to strip_digits(), not "new_str". Finally do not use "string" as a variable name as string is already used by python.
Oct 16 '12 #3

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

Similar topics

6
3227
by: roopa | last post by:
I have declared a class with name List; and in main() function, i have declared the List object as follows class List { public: List() { cout<<"In List Constuctor";
6
2759
by: Gonnasi | last post by:
With >glob.glob("*") or >os.listdir(cwd) I can get a combined file list with directory list, but I just wanna a bare file list, no directory list. How to get it? Tons of thanks in advance!
3
3391
by: news.bellatlantic.net | last post by:
I have a fundraising database for an organization. Donations come in from current members anad are found by using a combo box. If the member is found, the After Update macro switches to another form where the donation is entered. The problem is that if the donor is not a member, the On Not in List macro won't work for me bringing up a form with a new member number and all the fields that have to be filled out. I guess that the After...
2
2196
by: ormy28 | last post by:
I really need some help with the following problem if anyone would be willing. I need a list box to list the opposite of what appears in a query. Heres the details: My database is for a doctors surgery, and this includes the tables tblPatients, tblDoctors and tblAppointments. tblAppointments has an Appointment ID and also includes the Patient ID (from tblPatient) and Doctor ID (from tblDoctor) plus the start and end time of the
1
2974
by: tina.boroff | last post by:
I have 3 boxes that essentially use the same code for not in List events (Thank you to David for all of your help on that one). The code opens another form if the user wants to enter data that is not on the list. This works fantastic now. My problem is now with another box. It shows results in a dropdown box based on a query of the results in the box above. The query works great. However, I can not find a way to use the not in list...
0
1255
by: BeccyBoo | last post by:
This has probably been posted before but i've searched and couldn't find the answer I'm looking for (or just couldn't understand it) but here's what i'm trying to do: i have a table (tbl_participants). One field on this table is R_Category which looks up the table tbl_Category (field "Category"). I have created a form (frm_Participants) based on tbl_Participants. This form has a combobox on it for the R_Category field. I have placed...
5
11892
by: jung_h_park | last post by:
From: jung_h_park@yahoo.com Newsgroups: microsoft.public.dotnet.framework.aspnet Subject: Dropdown List not retaining its SelectedValue Date: Mon, 26 Jun 2006 21:02:57 -0700 Hello, My dropdown list control does not retain its SelectedValue. Unless I read the SelectedValue right after the control has been loaded, populated, and assigned with its original value (and of course that is
0
3486
by: webmaster | last post by:
Pardon my being a total C# noob. I'm trying to take apart the dotNet Time Tracker dotNet C# starterkit sample application and replicate a part of the code. At a high level, I have a very simple SQL server table and stored procedure which I have no problems binding from directly from an ASP.NET control... Table BOOK
5
52303
by: =?Utf-8?B?U3dhcG5pbA==?= | last post by:
hi, I want to copy the elements of one list to the other list. Is there any function to do this operation in C#. Plz explain with example.
3
2673
by: antar2 | last post by:
I already asked a similar question, but encounter problems with python... How can I concatenate the elements in each list of a list of lists list_of_listsA = , , ]
0
8481
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
8400
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
8924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8823
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
8602
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
5702
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
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2817
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
2
2058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.