Caleb Kunz
Caleb Kunz

Reputation: 25

Attempting to print with multiple inputs, and there are not enough inputted

I have written a code that prints out a wall of text that includes variables, once I get the variables to enter correctly the code will work correctly. I am attempting to input multiple variables in one line in python idle. I am using the split function to do so, and it only ever detects one input.

I have attempted to input this multiple times: 10.2.1 1 ACT10p2_Task1_TEAM4D_Template.py 10/30/2019 Caleb.Kunz N/A 4D Header.Code

activity, task, file, date, name, section, team, description = input("Type Activity, Task, File, Date, Name, Section, Team, Description ").split(),
print(" # Activity {0} Task {1}\n".format(activity, task),
"# File:  {0}\n".format(file),
"# Date:    {0}\n".format(date),
"# By:       {0}\n".format(name),
"# Section: {0}\n".format(section),
"# Team:    {0}\n".format(team),
"# \n",
"# ELECTRONIC SIGNATURE\n",
"# {0}\n".format(name),
"# \n",
"# The electronic signature above indicates the script\n",
"# submitted for evaluation is my individual work, and I\n",
"# have a general understanding of all aspects of its\n",
"# development and execution.\n",
"# \n",
"# Description: {0}\n".format(description))

I expect the output to be a wall of text that uses the inputs to print the wall with the inputs in the correct spots. It instead says it did not receive enough inputs

Upvotes: 0

Views: 48

Answers (3)

Barb
Barb

Reputation: 437

It is because you are setting 8 variables to your input line. If you type all of the variables this is your output:

Type Activity, Task, File, Date, Name, Section, Team, Description activity, task, file, date, name, section, team, description
 # Activity activity, Task task,
 # File:  File, # Date:    date, # By:       name,
 # Section: section,
 # Team:    team,
 #
 # ELECTRONIC SIGNATURE
 # name,
 #
 # The electronic signature above indicates the script
 # submitted for evaluation is my individual work, and I
 # have a general understanding of all aspects of its
 # development and execution.
 #
 # Description: description

You should consider using a class or function to set attributes.

Upvotes: 0

Anna
Anna

Reputation: 279

Try this one if you want split by comma:

activity, task, file, date, name, section, team, description = input(
        "Type Activity, Task, File, Date, Name, Section, Team, Description ").split(',')
print(" # Activity {0} Task {1}\n".format(activity, task),
"# File:  {0}\n".format(file),
"# Date:    {0}\n".format(date),
"# By:       {0}\n".format(name),
"# Section: {0}\n".format(section),
"# Team:    {0}\n".format(team),
"# \n",
"# ELECTRONIC SIGNATURE\n",
"# {0}\n".format(name),
"# \n",
"# The electronic signature above indicates the script\n",
"# submitted for evaluation is my individual work, and I\n",
"# have a general understanding of all aspects of its\n",
"# development and execution.\n",
"# \n",
"# Description: {0}\n".format(description))

test: test1,test2,test3,test4,test5,test6,test7,test8

Type Activity, Task, File, Date, Name, Section, Team, Description test1,test2,test3,test4,test5,test6,test7,test8
 # Activity test1 Task test2
 # File:  test3
 # Date:    test4
 # By:       test5
 # Section: test6
 # Team:    test7
 # 
 # ELECTRONIC SIGNATURE
 # test5
 # 
 # The electronic signature above indicates the script
 # submitted for evaluation is my individual work, and I
 # have a general understanding of all aspects of its
 # development and execution.
 # 
 # Description: test8

Upvotes: 0

luis.parravicini
luis.parravicini

Reputation: 1227

You have a trailing comma at the end of split(), that would make the whole statement a tuple. Remove the comma and it works.

Upvotes: 1

Related Questions