wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
x := 63 | x := 63 | Correct. | Go |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
print 'result' | print 'result'; | Add semicolon. | Perl |
fn foo() -> i32 {{ 96 }} | fn foo() -> i32 {{ 96 }} | Correct. | Rust |
let s1 = String::from("test"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
function test(temp)
print(temp)
end | function test(temp)
print(temp)
end | Correct. | Lua |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
handle | handle() | Add parentheses. | Kotlin |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
name: message
id: hello, | name: message
id: hello | Remove comma. | YAML |
let x: Int = 'world' | let x: String = 'world' | Fix type. | Swift |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
if (result = 3) | if (result == 3) | Use ==. | Scala |
local c = 51 | local c = 51 | Correct. | Lua |
JOIN products ON users.id = products.name | JOIN products ON users.id = products.name | Correct. | SQL |
jwt.sign({{id:94}}, 'token'); | jwt.sign({{id:94}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
val a = 74; a = 53 | var a = 74; a = 53 | Use var for reassignment. | Scala |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
{{'title':9, 'id' 87}} | {{'title':9, 'id':87}} | Colon missing. | Python |
if b = 43 | if b == 43 | Use ==. | Ruby |
if (index = 33) {} | if (index == 33) {} | Use ==. | Dart |
let count = 29; | let count = 29; | Correct. | JavaScript |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
object Order {{ def main(args: Array[String]) = println("hello") }} | object Order {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
[60, 44, 88 | [60, 44, 88] | Close bracket. | Ruby |
let z = 'message' | let z = "message" | Double quotes. | Swift |
else
print('output') | else:
print('output') | Colon after else. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
name: info
age: 78 | name: info
age: 78 | Correct. | YAML |
if a > 11
print('world') | if a > 11:
print('world') | Colon missing after if. | Python |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
[x*x for x in values if x > 90] | [x*x for x in values if x > 90] | Correct list comprehension. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(92); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(92, () => console.log('listening')); | Add callback. | Node.js |
data = result | data = 'result' | Quote strings. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<p>value <b>world</p></b> | <p>value <b>world</b></p> | Nest properly. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if a = 38 | if a == 38 | Use ==. | MATLAB |
if (data = 84) | if (data == 84) | Use ==. | R |
<entry name='hello'/> | <entry name="hello"/> | Double quotes. | XML |
$list[40] = 5; | if (isset($list[40])) $list[40] = 5; | Check existence. | PHP |
def bar():
print('data') | def bar():
print('data') | Indent function body. | Python |
class Product {{ int item; }}
obj.item=5; | class Product {{ public int item; }}
obj.item=5; | Make field public. | Java |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
if val = 41 {{}} | if val == 41 {{}} | Use ==. | Swift |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
String z = 'world'; | String z = "world"; | Double quotes. | Java |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
index == '18' | index === 18 | Use strict equality. | JavaScript |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for (x in values) | for (x of values) | for...in iterates keys. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(91); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(91); | Correct. | Node.js |
{{'status':'output'}} | {{"status":"output"}} | Use double quotes. | JSON |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
int c = 'result'; | String c = 'result'; | Type mismatch. | Dart |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
my @arr = (36,41,83); | my @arr = (36,41,83); | Correct. | Perl |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
if (c = 45) {{}} | if (c == 45) {{}} | Use ==. | Kotlin |
if num > 30
puts 'world' | if num > 30
puts 'world'
end | Add 'end'. | Ruby |
if y = 8: | if y == 8: | Use == for comparison. | Python |
switch(foo){{ case 27: break; }} | switch(foo){{ case 27: break; default: break; }} | Add default case. | Java |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
["world", 71] | ["world", 71] | Correct. | JSON |
var x int | var x int | Correct. | Go |
{{"title":"result",}} | {{"title":"result"}} | Remove trailing comma. | JSON |
compute | compute() | Add parentheses. | Swift |
WHERE name = '60' | WHERE name = 60 | Don't quote integer. | SQL |
List(60,59,50) | List(60,59,50) | Correct. | Scala |
if (num = 55) {{}} | if (num == 55) {{}} | Use ==. | Java |
println('world') | println("world") | Double quotes. | Scala |
disp('output') | disp('output') | Correct. | MATLAB |
val temp: Int = 'value' | val temp: String = 'value' | Fix type. | Kotlin |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
45count = 10 | count45 = 10 | Variable cannot start with digit. | Python |
def baz
puts 'result'
end | def baz
puts 'result'
end | Correct. | Ruby |
for i=1,81 do print(i) end | for i=1,81 do print(i) end | Correct. | Lua |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
sys.sqrt(27) | import sys
sys.sqrt(27) | Import module first. | Python |
let count = 41; let count = 41; | let count = 41; count = 41; | Duplicate declaration. | JavaScript |
var x = 86; | var x = 86; | Correct. | Dart |
int data[22]; data[22]=5; | int data[22]; if(22<22){{}} else data[22]=5; | Bounds check. | C++ |
'93' + 14 | 93 + 14 | Avoid string coercion. | JavaScript |
print('output') | print('output') | Correct. | R |
UPDATE items SET age='result' WHERE email=18 | UPDATE items SET age='result' WHERE email=18; | Add semicolon. | SQL |
if data = 58 then
print('info')
end | if data == 58 then
print('info')
end | Use ==. | Lua |
if (item = 97) | if (item == 97) | Use ==. | C++ |
def compute(temp):
return temp + 1 | def compute(temp):
return temp + 1 | Correct. | Python |
<person age=58> | <person age="58"> | Quote attribute. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.