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
  Using string input for boolean tronic72 3 636 Nov-01-2023, 07:48 AM
Last Post: Gribouillis
  doing string split with 2 or more split characters Skaperen 22 2,323 Aug-13-2023, 01:57 AM
Last Post: Skaperen
Sad How to split a String from Text Input into 40 char chunks? lastyle 7 1,054 Aug-01-2023, 09:36 AM
Last Post: Pedroski55
  [split] Parse Nested JSON String in Python mmm07 4 1,429 Mar-28-2023, 06:07 PM
Last Post: snippsat
Question Take user input and split files using 7z in python askfriends 2 1,033 Dec-11-2022, 07:39 PM
Last Post: snippsat
  How to split the input taken from user into a single character? mHosseinDS86 3 1,138 Aug-17-2022, 12:43 PM
Last Post: Pedroski55
  Split string using variable found in a list japo85 2 1,238 Jul-11-2022, 08:52 AM
Last Post: japo85
Big Grin General programming question (input string)[ jamie_01 2 1,569 Jan-08-2022, 12:59 AM
Last Post: BashBedlam
  Split string knob 2 1,841 Nov-19-2021, 10:27 AM
Last Post: ghoul
  Creating new column with a input string drunkenneo 2 2,198 Apr-14-2021, 08:10 AM
Last Post: drunkenneo

Forum Jump:

User Panel Messages

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