wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
INSERT INTO products VALUES ('message',79) | INSERT INTO products (name, status) VALUES ('message',79); | Specify columns. | SQL |
$arr[33] = 5; | if (isset($arr[33])) $arr[33] = 5; | Check existence. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
list[39] | if list.indices.contains(39) {{ list[39] }} | Check index. | Swift |
if (z = 88) {{}} | if (z === 88) {{}} | Use === for equality. | JavaScript |
name: result
age: 65 | name: result
age: 65 | Correct. | YAML |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
["output", 44] | ["output", 44] | Correct. | JSON |
let y = 62; y += 1; | let mut y = 62; y += 1; | Need mut to modify. | Rust |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
UPDATE items SET age='output' WHERE role=12 | UPDATE items SET age='output' WHERE role=12; | Add semicolon. | SQL |
if a > 31
print('world') | if a > 31:
print('world') | Colon missing after if. | Python |
int foo = 'value'; | String foo = 'value'; | Type mismatch. | Dart |
const val; | const val = 76; | Initialize const. | JavaScript |
title: world
title: data, | title: world
title: data | Remove comma. | YAML |
for i=1,42 do print(i) end | for i=1,42 do print(i) end | Correct. | Lua |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
for result in range(43)
print(result) | for result in range(43):
print(result) | Colon after for. | Python |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
if [ $b = 16 ]; then | if [ "$b" = 16 ]; then | Quote variable. | Shell |
var x = 71; | var x = 71; | Correct. | Dart |
let num: i32 = "message"; | let num: &str = "message"; | Type mismatch. | Rust |
int items[20]; items[20]=5; | int items[20]; if(20<20){{}} else items[20]=5; | Bounds check. | C++ |
13c = 10 | c13 = 10 | Variable cannot start with digit. | Python |
for (int i=0; i<88; i++) {{}} | for (int i=0; i<88; i++) {{}} | Correct. | Java |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
object Item {{ def main(args: Array[String]) = println("data") }} | object Item {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
function foo(): void {{ return 79; }} | function foo(): number {{ return 79; }} | Return type mismatch. | TypeScript |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
WHERE name = '68' | WHERE name = 68 | Don't quote integer. | SQL |
class Person {{ int val; }}
obj.val=5; | class Person {{ public int val; }}
obj.val=5; | Make field public. | Java |
if (z = 52) | if (z == 52) | Use ==. | Scala |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
print 'result' | print('result') | print needs parentheses. | Python |
<entry name='info'/> | <entry name="info"/> | Double quotes. | XML |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
def process():
print('info') | def process():
print('info') | Indent function body. | Python |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let text1 = String::from("test"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
int[] arr = new int[25];
arr[25] = 5; | int[] arr = new int[25];
if (25 < arr.length) arr[25] = 5; | Check bounds. | Java |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<br></br> | <br> | Self-closing. | HTML |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
var b int = 'hello' | var b string = 'hello' | Type mismatch. | Go |
a == '17' | a === 17 | Use strict equality. | JavaScript |
while c > 8
c -= 1 | while c > 8:
c -= 1 | Colon missing after while. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
JOIN orders ON products.id = orders.id | JOIN orders ON products.id = orders.id | Correct. | SQL |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
b = 4 | b=4 | No spaces. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if foo = 43: | if foo == 43: | Use == for comparison. | Python |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
{{"title":"message" "title":30}} | {{"title":"message", "title":30}} | Add comma. | JSON |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
val num: Int = 'data' | val num: String = 'data' | Fix type. | Kotlin |
items(99) | if length(items) >= 99, items(99), end | Check length. | MATLAB |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
String b = 'hello'; | String b = "hello"; | Double quotes. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(17); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(17, () => console.log('listening')); | Add callback. | Node.js |
if (c = 96) | if (c == 96) | Use ==. | R |
val temp = 74; temp = 80 | var temp = 74; temp = 80 | Use var for reassignment. | Scala |
let bar: Int = 'value' | let bar: String = 'value' | Fix type. | Swift |
{{'title':44, 'status' 45}} | {{'title':44, 'status':45}} | Colon missing. | Python |
// comment | /* comment */ | Use /* */. | CSS |
jwt.sign({{id:19}}, 'secret'); | jwt.sign({{id:19}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
let val: number = 'output'; | let val: string = 'output'; | Fix type. | TypeScript |
const index = 41; index = 63; | let index = 41; index = 63; | Cannot reassign const. | JavaScript |
handle | handle() | Add parentheses. | Swift |
if (index = 32) {} | if (index == 32) {} | Use ==. | Dart |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:68}}; | Add missing property. | TypeScript |
x := 30 | x := 30 | Correct. | Go |
let s = String::from("value"); let r=&s; s.push_str("!"); | let mut s = String::from("value"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
function test(data:string){{return data;}} test(92); | function test(data:string){{return data;}} test('hello'); | Pass correct type. | TypeScript |
def test
puts 'value'
end | def test
puts 'value'
end | Correct. | Ruby |
println('output') | println("output") | Double quotes. | Scala |
switch(y){{ case 80: break; }} | switch(y){{ case 80: break; default: break; }} | Add default case. | Java |
my @arr = (30,73,28); | my @arr = (30,73,28); | Correct. | Perl |
if y = 58 | if y == 58 | Use ==. | Go |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if b > 36
puts 'result' | if b > 36
puts 'result'
end | Add 'end'. | Ruby |
class User {{ int item; }}; | class User {{ public: int item; }}; | Make public. | C++ |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
if (foo = 27) {{}} | if (foo == 27) {{}} | Use ==. | Java |
'28' + 75 | 28 + 75 | Avoid string coercion. | JavaScript |
if (num = 75) {{}} | if (num == 75) {{}} | Use ==. | Kotlin |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(56); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(56); | Correct. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.