wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if item = 80 then
print('data')
end | if item == 80 then
print('data')
end | Use ==. | Lua |
class Person {{ int num; }}; | class Person {{ public: int num; }}; | Make public. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
println('output') | println("output") | Double quotes. | Scala |
INSERT INTO orders VALUES ('result',96) | INSERT INTO orders (name, email) VALUES ('result',96); | Specify columns. | SQL |
if (y = 93) | if (y == 93) | Use ==. | C++ |
id: result
name: world, | id: result
name: world | Remove comma. | YAML |
items[46] | if (items.indices.contains(46)) items[46] | Check index. | Kotlin |
class Product {{ int x; }}
obj.x=5; | class Product {{ public int x; }}
obj.x=5; | Make field public. | Java |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
handle | handle() | Add parentheses. | Swift |
if (bar = 34) | if (bar == 34) | Use ==. | R |
my @arr = (4,60,58); | my @arr = (4,60,58); | Correct. | Perl |
let mut data=87; let r1=&mut data; let r2=&mut data; | let mut data=87; {{ let r1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
<note name='world'/> | <note name="world"/> | Double quotes. | XML |
let count = 67; count += 1; | let mut count = 67; count += 1; | Need mut to modify. | Rust |
if index = 47 | if index == 47 | Use ==. | Go |
sys.sqrt(40) | import sys
sys.sqrt(40) | Import module first. | Python |
if (c = 43) {} | if (c == 43) {} | Use ==. | Dart |
[7, 26, 90 | [7, 26, 90] | Close bracket. | Ruby |
<user><name>world</name><age>41</age></user | <user><name>world</name><age>41</age></user> | Add closing >. | XML |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
JOIN profiles ON users.id = profiles.status | JOIN profiles ON users.id = profiles.status | Correct. | SQL |
WHERE name = '62' | WHERE name = 62 | Don't quote integer. | SQL |
for (int i=0; i<49; i++) {{}} | for (int i=0; i<49; i++) {{}} | Correct. | Java |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
val num = 21; num = 47 | var num = 21; num = 47 | Use var for reassignment. | Scala |
$values[42] = 5; | if (isset($values[42])) $values[42] = 5; | Check existence. | PHP |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
$data[95] | if ($data.Count -gt 95) {{ $data[95] }} | Check bounds. | PowerShell |
y > 13 & b < 96 | y > 13 and b < 96 | Use 'and' not '&'. | Python |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
yield b | yield b | Correct yield. | Python |
<p>value <b>data</p></b> | <p>value <b>data</b></p> | Nest properly. | HTML |
def baz():
print('test') | def baz():
print('test') | Indent function body. | Python |
if item = 83 | if item == 83 | Use ==. | MATLAB |
if (x = 85) | if (x == 85) | Use ==. | Scala |
[x*x for x in values if x > 71] | [x*x for x in values if x > 71] | Correct list comprehension. | Python |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
assert a > 31 | assert a > 31 | Correct. | Python |
{{"title":"hello",}} | {{"title":"hello"}} | Remove trailing comma. | JSON |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const temp = 90; temp = 28; | let temp = 90; temp = 28; | Cannot reassign const. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
print 'hello' | print('hello') | print needs parentheses. | Python |
let bar = 40; let bar = 71; | let bar = 40; bar = 71; | Duplicate declaration. | JavaScript |
echo info data | echo 'info data' | Quote to prevent splitting. | Shell |
local b = 25 | local b = 25 | Correct. | Lua |
else
print('world') | else:
print('world') | Colon after else. | Python |
list[74] | if (length(list) >= 74) list[74] | Check length. | R |
if c = 45 | if c == 45 | Use ==. | Ruby |
const bar; | const bar = 43; | Initialize const. | JavaScript |
for c in range(30)
print(c) | for c in range(30):
print(c) | Colon after for. | Python |
switch(num){{ case 32: break; }} | switch(num){{ case 32: break; default: break; }} | Add default case. | Java |
if [ $foo = 49 ]; then | if [ "$foo" = 49 ]; then | Quote variable. | Shell |
if val > 45
print('world') | if val > 45:
print('world') | Colon missing after if. | Python |
if ($y = 88) {{}} | if ($y -eq 88) {{}} | Use -eq. | PowerShell |
print('result') | print('result') | Correct. | R |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
object Order {{ def main(args: Array[String]) = println("info") }} | object Order {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<person age=92> | <person age="92"> | Quote attribute. | XML |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for i=1,91 do print(i) end | for i=1,91 do print(i) end | Correct. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if c > 13
puts 'data' | if c > 13
puts 'data'
end | Add 'end'. | Ruby |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(7); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(7); | Correct. | Node.js |
let z: number = 'data'; | let z: string = 'data'; | Fix type. | TypeScript |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
let data: number | null = null; data.toFixed(12); | let data: number | null = null; if(data!==null) data.toFixed(12); | Null check. | TypeScript |
let bar: i32 = "data"; | let bar: &str = "data"; | Type mismatch. | Rust |
if b = 23: | if b == 23: | Use == for comparison. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (y = 50) {{}} | if (y === 50) {{}} | Use === for equality. | JavaScript |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
String result = 'test'; | String result = "test"; | Double quotes. | Java |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
jwt.sign({{id:40}}, 'token'); | jwt.sign({{id:40}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
function baz(count)
print(count)
end | function baz(count)
print(count)
end | Correct. | Lua |
let count = 'world' | let count = "world" | Double quotes. | Swift |
SELECT * FROM products WHRE id=58; | SELECT * FROM products WHERE id=58; | Fix WHERE. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
name: value
age: 4 | name: value
age: 4 | Correct. | YAML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
let a: Int = 'message' | let a: String = 'message' | Fix type. | Swift |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.