Python Forum
Is it possible to avoid apostrophes ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is it possible to avoid apostrophes ?
#1
Hi all ! Is it I possible to avoid apostrophes in my matrix, at the end of the file ??

# file9
def pause():
   input("Press ENTER to continue")


S = 'spam'
print(S[0], S[-2])
print(S[0], S[2])
N = 42
print(str(N))
print(str(N) + 'abc')
print(' ' + str(N))
pause()
M = [[x * y for y in range(1, 10)] for x in range(1, 10)]

for x in range(len(M)):
   print(M[x])

pause()
for i in range(len(M)):
   for j in range(len(M)):
       if len(str(M[i][j])) == 1:
           M[i][j] = " " + str(M[i][j])
       else:
           M[i][j] = str(M[i][j])

for x in range(len(M)):
   print(M[x])
Reply
#2
By parenthesis I mean single quote, which appear at the display of the matrix.
Reply
#3
I run your code. It happens that the digits in the matrix are strings. Strings are represented in quotes. Double or single. You have to turn them into integers
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#4
At the first print of M you see integers. The marix is irregular at the beginning. At the second print it is regular. So, I think it is impossible to have any better edition of the matrix. Thanks for your reply.
Reply
#5
There is nothing here with the matrix. You explicitly are using the str() method to turn the values to strings. Lines 23, 25
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#6
Quote:By parenthesis I mean single quote
single quotes are called apostrophe or simply single quotes
there should be two words, but there are not.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to remove apostrophes in a matrix sylas 4 3,471 May-06-2018, 05:07 PM
Last Post: killerrex
  remove apostrophes in list sparkz_alot 5 9,953 Jul-21-2017, 09:21 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

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