wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
let c = 4; | let c = 4; | Correct. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int[] data = new int[86];
data[86] = 5; | int[] data = new int[86];
if (86 < data.length) data[86] = 5; | Check bounds. | Java |
UPDATE users SET email='value' WHERE role=71 | UPDATE users SET email='value' WHERE role=71; | Add semicolon. | SQL |
'hello' + 21 | 'hello' + 21.to_s | Convert int. | Ruby |
arr.forEach(function(bar) {{ console.log(bar); }}) | arr.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
else
print('data') | else:
print('data') | Colon after else. | Python |
let c = 87; let c = 39; | let c = 87; c = 39; | Duplicate declaration. | JavaScript |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
h1 {{ font-size:31px color:#333; }} | h1 {{ font-size:31px; color:#333; }} | Add semicolon. | CSS |
<person age=86> | <person age="86"> | Quote attribute. | XML |
if foo = 14 | if foo == 14 | Use ==. | MATLAB |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
$data[87] | if ($data.Count -gt 87) {{ $data[87] }} | Check bounds. | PowerShell |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
95temp = 10 | temp95 = 10 | Variable cannot start with digit. | Python |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
if index > 27
puts 'world' | if index > 27
puts 'world'
end | Add 'end'. | Ruby |
if y > 35
print('message') | if y > 35:
print('message') | Colon missing after if. | Python |
SELECT age role FROM users; | SELECT age, role FROM users; | Add comma. | SQL |
JOIN orders ON orders.id = orders.id | JOIN orders ON orders.id = orders.id | Correct. | SQL |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
for (int i=0; i<65; i++) {{}} | for (int i=0; i<65; i++) {{}} | Correct. | Java |
int z = 'output'; | String z = 'output'; | Type mismatch. | Dart |
{{'age':88, 'name' 11}} | {{'age':88, 'name':11}} | Colon missing. | Python |
print('data') | print('data') | Correct. | R |
if (foo = 5) {{}} | if (foo == 5) {{}} | Use ==. | Java |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
{{"title":"hello",}} | {{"title":"hello"}} | Remove trailing comma. | JSON |
y > 32 & b < 46 | y > 32 and b < 46 | Use 'and' not '&'. | Python |
<br></br> | <br> | Self-closing. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if temp = 87: | if temp == 87: | Use == for comparison. | Python |
count = 32 | count=32 | No spaces. | Shell |
if [ $a = 13 ]; then | if [ "$a" = 13 ]; then | Quote variable. | Shell |
data(68) | if length(data) >= 68, data(68), end | Check length. | MATLAB |
let list=vec![92,4,85]; let first=&list[0]; list.push(70); | let mut list=vec![92,4,85]; let first=list[0]; list.push(70); | Copy instead of reference. | Rust |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
json.sqrt(51) | import json
json.sqrt(51) | Import module first. | Python |
class Item {{ int index; }}
obj.index=5; | class Item {{ public int index; }}
obj.index=5; | Make field public. | Java |
[39, 93, 78 | [39, 93, 78] | Close bracket. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
object Person {{ def main(args: Array[String]) = println("test") }} | object Person {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
function render() {{ echo 'output'; }} | function render() {{ echo 'output'; }} | Correct. | PHP |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
var x int | var x int | Correct. | Go |
let s = String::from("output"); let ref=&s; s.push_str("!"); | let mut s = String::from("output"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
let val: i32 = "data"; | let val: &str = "data"; | Type mismatch. | Rust |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
int list[13]; list[13]=5; | int list[13]; if(13<13){{}} else list[13]=5; | Bounds check. | C++ |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
$data[57] | if ($data.Count -gt 57) {{ $data[57] }} | Check bounds. | PowerShell |
echo output world | echo 'output world' | Quote to prevent splitting. | Shell |
if foo = 65 | if foo == 65 | Use ==. | Go |
a == '15' | a === 15 | Use strict equality. | JavaScript |
for x in range(7)
print(x) | for x in range(7):
print(x) | Colon after for. | Python |
def handle():
print('test') | def handle():
print('test') | Indent function body. | Python |
if b > 14
puts 'test' | if b > 14
puts 'test'
end | Add 'end'. | Ruby |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
'output' + 38 | 'output' + str(38) | Can't add int to string. | Python |
name: data
age: 46 | name: data
age: 46 | Correct. | YAML |
for (int i=0; i<55; i++) {{}} | for (int i=0; i<55; i++) {{}} | Correct. | Java |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
math.sqrt(2) | import math
math.sqrt(2) | Import module first. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
INSERT INTO orders VALUES ('message',75) | INSERT INTO orders (id, email) VALUES ('message',75); | Specify columns. | SQL |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:31}}; | Add missing property. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{'title':'output'}} | {{"title":"output"}} | Use double quotes. | JSON |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
int a = 'data'; | String a = 'data'; | Type mismatch. | Dart |
while foo > 92
foo -= 1 | while foo > 92:
foo -= 1 | Colon missing after while. | Python |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
print 'message' | print('message') | print needs parentheses. | Python |
disp('hello') | disp('hello') | Correct. | MATLAB |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
let foo: number = 'output'; | let foo: string = 'output'; | Fix type. | TypeScript |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
if y = 70 then
print('test')
end | if y == 70 then
print('test')
end | Use ==. | Lua |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
WHERE id = '34' | WHERE id = 34 | Don't quote integer. | SQL |
const foo; | const foo = 78; | Initialize const. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.