Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9307343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:22:24+00:00 2026-06-19T00:22:24+00:00

Okay, the problem I have here is that I’ve got this .txt file Python

  • 0

Okay, the problem I have here is that I’ve got this .txt file Python imports into a dictionary.

What is does is it takes the values from the text files, that are in this Specific format:

a 0.01                   
b 0.11
c 1.11
d 0.02

^ (In code format because It wouldn’t wouldn’t stack it like in the .txt, not actually code)
and then puts them into a dictionary like this:

d = { ‘a’:’0.01′, ‘b’:’0.11, ect….}

Well, I’m using this so that it will change whatever value the user inputs (Later in the script) into whatever is defined inside the dictionary.

The problem is if I try and make it incorporate a space, it just doesn’t work.

Like, I finished the letters, and their corresponding values in the .txt and began going onto symbols:

For example:

& &
* * 

(so that when entered into the dictionary, the corresponding values are printed when I have it print the translated message) (I could change them up, but I decided to leave them as they are)

The problem arises when I try and have it make a space in the user input correspond to a space or another value in the translated message.

I tried leaving a row blank in my .txt, so that (space) is to (space)

But later, when it tried to load the .txt, it gave me an error, saying that: “need more than one value to unpack”

Can someone help me out?

EDIT: Adding code as requested.

TRvalues = {}
with open(r"C:\Users\Owatch\Documents\Python\Unisung Net Send\nsed.txt") as f:
    for line in f:
        (key, val) = line.split()
        TRvalues[key] = val
if TRvalues == False:
    print("\n\tError encountered while attempting to load the .txt file")
    print("\n\t The file does not contain any values")
else:
    print("Dictionary Loaded-")

Sample text file:

a 0.01
b 0.11
c 1.11
d 0.02
e 0.22
f 2.22
g 0.03
h 0.33
i 3.33
j 0.04
k 0.44
l 4.44
m 0.05
n 0.55
o 5.55
p 0.06
q 0.66
r 6.66
s 0.07
t 0.77
u 7.77
v 0.08
w 0.88
x 8.88
y 0.09
z 0.99

I get this error when I attempt to run the script:

Traceback (most recent call last):
  File "C:/Users/Owatch/Documents/Python/Unisung Net Send/Input Encryption 0.02.py", line 17, in <module>
    (key, val) = line.split()
ValueError: need more than 0 values to unpack

EDIT: Thanks for downvoting everybody! I’m now no longer able to ask questions.

Believe it or not I DO know the rules for this website, and DID research this before asking on Stack Overflow. It IS helpful for other people as well. What a nice community. Hopefully the people who answered did not downvote it. I appreciate what they did.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T00:22:25+00:00Added an answer on June 19, 2026 at 12:22 am

    If I understand correctly, you’re trying to use a space both as an unquoted value and as a delimiter, which won’t work. I’d use the csv module and its quoting rules. For example (assuming you’re using Python 3 from your print functions):

    import csv
    
    with open('nsed.txt', newline='') as f:
        reader = csv.reader((line.strip() for line in f), delimiter=' ')
        TRvalues = dict(reader)
    
    print(TRvalues)
    

    with an input file of

    a 0.01
    b 0.11
    c 1.11
    d 0.02
    " " " "
    

    gives

    {' ': ' ', 'a': '0.01', 'b': '0.11', 'c': '1.11', 'd': '0.02'}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, here is my problem: I have a form that requires to have two
Okay here's my situation. I have a php file that contains a simple form
Okay here is the problem, I have images of different sizes, but that doesn't
Okay, so here's my problem: I have a list of members on a website,
I have a problem with (for me to complicated) MySql query. Okay, here is
Okay, so I've got a problem - and I'd love to have it fixed.
Okay, here is the problem. I have an unordered list with a bunch of
Okay so here is the problem: I have 3 classes MyClass1 and MyClass2 and
Okay, so we have a utility here in-house that generates business-model classes from our
Okay StackOverflow - this is a weird one. The Problem So I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.