Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
input string split
#1
Hello. Self-teaching and new to Python. I am trying to code a program where I ask a user for 2 points and attempt to calculate the distance. I keep running into errors when I try to take the inputted string, seperated by commas, and split them into the list.

For example, the question and input from the user is:
Quote:Enter x1 and y1 for Point 1: 1.9, -2.4
Enter x2 and y2 for Point 2: 5, 6
This is the code I have so far:
import math
import string
from string import split    

[quote]x_input = input("Enter x1 and y1 for Point 1: ")
y_input = input("Enter x2 and y2 for Point 2: ")


x = split(x_input, ",")


print (x[1])
The error I keep getting is "AttributeError: 'tuple' object has no attribute 'split'".

Any help?
Reply


Messages In This Thread
input string split - by Eric7Giants - Nov-13-2019, 06:12 PM
RE: input string split - by Gribouillis - Nov-13-2019, 06:33 PM
RE: input string split - by Eric7Giants - Nov-13-2019, 06:43 PM
RE: input string split - by Gribouillis - Nov-13-2019, 07:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python win32api keybd_event: How do I input a string of characters? JaneTan 3 221 Oct-19-2020, 04:16 AM
Last Post: deanhystad
  Split string between two different delimiters, with exceptions DreamingInsanity 2 297 Aug-24-2020, 08:23 AM
Last Post: DreamingInsanity
  split string enigma619 1 283 May-20-2020, 02:47 PM
Last Post: perfringo
  Split string with multiple delimiters and keep the string in "groups" DreamingInsanity 4 557 May-12-2020, 09:31 AM
Last Post: DeaD_EyE
  Split and sort input file aawaleh 4 564 Apr-10-2020, 09:59 PM
Last Post: aawaleh
  Split a long string into other strings with no delimiters/characters krewlaz 4 574 Nov-15-2019, 02:48 PM
Last Post: ichabod801
  with input remove a string from the list konsular 3 607 Oct-12-2019, 09:25 AM
Last Post: konsular
  [split] capitalize dict keys for display in string newbieAuggie2019 3 713 Oct-10-2019, 10:50 AM
Last Post: perfringo
  How to split string after delimiter SriRajesh 1 497 Sep-11-2019, 11:25 AM
Last Post: metulburr
  [split] NameError: name 'lo' is not defined when using input ? Cedmo 2 925 Jul-05-2019, 09:39 PM
Last Post: Cedmo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020