• Register

Recent questions tagged python-string

0 votes
1 answer 11 views
Problem: I'm using Max OS X 10.10.3, and I finally got the graphics.py to show in Python 3, before it was saying no module existed. However, now when I try import graphics, or from graphics import *, I get the message: "source code string cannot contain null bytes" Does any Mac user (using Python 3) perhaps know what is wrong? Has anyone used the Zelle book and his graphics.py module?
asked Feb 15 Mashhoodch 9.1k points
0 votes
1 answer 11 views
Problem: On the last line, I got this error: builtins.TypeError: must be str, not bytes File "C:\PythonExamples\XmlReportGeneratorExample.py", line 29, in <module> doc.write(outFile) File "c:\Python32\Lib\site-packages\lxml\etree.pyd", line 1853, in lxml.etree._ElementTree.write (src/ ... etree.c:89527) I've installed Python 3.2, and I've installed lxml-2.3.win32-py3.2.exe. On Python 2.7 it works.
asked Jan 9 Mashhoodch 9.1k points
0 votes
1 answer 74 views
I was looking for a way to run an external process from python script and print its stdout messages during the execution. The code below works, but prints no stdout output during runtime. When it exits I am getting the following error: sys.stdout.write(nextline) TypeError:must ... .stdout.write(nextline) sys.stdout.flush() output = p.communicate()[0] exitCode = p.returncode I am using python 3.3.2
asked Oct 24, 2020 psandprop 2.4k points
0 votes
1 answer 114 views
I am trying to figure out why this error showing in my case and searching several website didn't get the desired result. In this website can someone can someone show me correct way to solve this ValueError: Must pass DataFrame with boolean values only.
asked Sep 14, 2020 Daniel Anderson 4k points
1 vote
1 answer 83 views
Problem: I was trying to remove a letter from a string by writing this python program: def removechar(p, q) : counts = p.count(q) p = list(p) while counts : p.remove(q) counts -= 1 print(p) if __name__ == '__main__' : p = "nooneisallinall" removechar(p,'n') And the program ... 'l', 'l', 'i', 'a', 'l', 'l'] How can I get the output as string after removing the specific letter. Thanks in advance.
asked May 16, 2020 samhaz 5k points
1 vote
2 answers 2.1K views
Problem: I was trying to insert data from one of my dictionaries into my database for that I wrote the code: def all_db_inserts(dbinformation): try: rows = dbinfo['datarows'] for row in rows: field_names = ",".join(["'{0}'".format(x) for x in row.keys()] ... this error message when I try to run this(using sample data): TypeError: sequence item 0: expected string, int found Can anyone help me out?
asked Apr 5, 2020 LizzyM 6.1k points
1 vote
1 answer 589 views
Problem: I am getting the following error : error: array initializer must be an initializer list or string literal For the array; char x[80] = GetString(); Can any body explain or help?
asked Apr 2, 2020 LizzyM 6.1k points
1 vote
1 answer 35 views
Problem: I am new in pyhton programing language . I was trying to check if two strings are anagrams python. But I fail repitedly. The code I wrote to check if two strings are anagrams is: def IsAnagram(str1,str2): str1 = input("Enter your first string : ") ... , line 4 str1 = input("Enter your first string : ") ^ IndentationError: expected an indented block What is the problem can anyone tell?
asked Apr 2, 2020 LizzyM 6.1k points
1 vote
1 answer 37 views
Problem: I am beginner in pyhton prgramming language, I tried to convert string array to int array using python so I wrote a code which contains- testing_list = ['4', '2', '3', '9', '5'] And my code is: testing_list = ['4', '2', '3', '9', '5 ... list is : str(testing_list) Converted list is : str(testing_list) why am I not getting the converted result and what is the way to get the acurate result?
asked Mar 29, 2020 LizzyM 6.1k points
1 vote
1 answer 21 views
Problem: I was tring to find the length of a string in python. So I wrote a code: string = 0 for c in "popular": string+==1 print (string) which gives following error; File "ab.py", line 3 string+==1 ^ SyntaxError: invalid syntax Is this the right way to do this or there are other waysto find this out?
asked Mar 28, 2020 LizzyM 6.1k points
1 vote
1 answer 23 views
Problem: I am beginner in pyhton programing. I have a dictionary of string and int and that is: Dictionary = { "Hola": 65, "tart" : 32, "star" : 34, "site" : 55, "pearl" : 88 } Supose I have to remove a key from this dictionary what should I do next.
asked Mar 28, 2020 LizzyM 6.1k points
0 votes
1 answer 19 views
I am new to python programming.. I was trying to check if a string is empty or whitespace in a code : Mystr= "" Yourstr = " " print ("This string is empty : ", end = "") if(not Yourstr): print ("Yes") print ("This string is empty : ", end = "") if(not Mystr): print ("No") It&rsquo;s output is : This string is empty : This string is empty : No Its not giving me actual result what can I do now?
asked Mar 16, 2020 LizzyM 6.1k points
0 votes
1 answer 87 views
I am new to python programming. I was trying to compare two strings, I wrote a code to compare: YourStr = "one" MyStr = "one" if YourStr = MyStr print("Two strings are same") else print("Two strings are not same") But it gives an error: File "main.py", line 4 if YourStr = MyStr ^ SyntaxError: invalid syntax Whats wrong in my code and how can I compare two string but it is not case sensitive?
asked Mar 16, 2020 LizzyM 6.1k points
0 votes
1 answer 24 views
I am new to python programming I was trying to check if a letter is uppercase in python. I wrote some code to check this statement : import string def UpperCase(s_str): for x in s_str: if x not in string.UpeerCase: return False return True But I can not get the actual ... last): File "<stdin>", line 1, in <module> NameError: name 'LoWWE' is not defined Can anyone help me to solve this thing?
asked Mar 14, 2020 LizzyM 6.1k points
1 vote
1 answer 41 views
Problem: Hello I am starting my programming experience with python recently. I&rsquo;ve been surfing over the internet for a program that can remove punctuation from a String. I&rsquo;ve found many of them but still can&rsquo;t understand them. I am looking for a program written in very basic codes. If possible, please write me a program which would be easy to understand for me. Thanks
asked Mar 8, 2020 Gavin 15.3k points
1 vote
1 answer 65 views
Problem: I am working on python string. import string import re str = "Hello" b = 0 srr = "" for a in str: srr[b] = a #'str' object does not support item assignment b = b + 1 print (srr) This is my sample code. I was trying to read some characters from a string and put it into another string like C or Java but it&rsquo;s not working for my case. Thanks. I must recognize your help.
asked Mar 7, 2020 Gavin 15.3k points
To see more, click for the full list of questions or popular tags.