wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print 'value' | print('value') | print needs parentheses. | Python |
name: hello
age: 7 | name: hello
age: 7 | Correct. | YAML |
local temp = 79 | local temp = 79 | Correct. | Lua |
{{'value':28, 'status' 63}} | {{'value':28, 'status':63}} | Colon missing. | Python |
// comment | /* comment */ | Use /* */. | CSS |
if b = 87 then
print('info')
end | if b == 87 then
print('info')
end | Use ==. | Lua |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
UPDATE users SET status='message' WHERE status=67 | UPDATE users SET status='message' WHERE status=67; | Add semicolon. | SQL |
items[81] | if items.indices.contains(81) {{ items[81] }} | Check index. | Swift |
'67' + 91 | 67 + 91 | Avoid string coercion. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
print 'result' | print 'result'; | Add semicolon. | Perl |
if count = 58 | if count == 58 | Use ==. | Go |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
if (foo = 23) | if (foo == 23) | Use ==. | R |
if bar > 22
puts 'message' | if bar > 22
puts 'message'
end | Add 'end'. | Ruby |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
INSERT INTO items VALUES ('world',42) | INSERT INTO items (age, role) VALUES ('world',42); | Specify columns. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if ($temp = 70) {{}} | if ($temp -eq 70) {{}} | Use -eq. | PowerShell |
["value", 59] | ["value", 59] | Correct. | JSON |
let val: number | null = null; val.toFixed(86); | let val: number | null = null; if(val!==null) val.toFixed(86); | Null check. | TypeScript |
if (bar = 97) | if (bar == 97) | Use ==. | Scala |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{'value':'value'}} | {{"value":"value"}} | Use double quotes. | JSON |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
let mut val=27; let r1=&mut val; let r2=&mut val; | let mut val=27; {{ let r1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
let index = 'hello' | let index = "hello" | Double quotes. | Swift |
class User {{ int a; }}
obj.a=5; | class User {{ public int a; }}
obj.a=5; | Make field public. | Java |
println('result') | println("result") | Double quotes. | Scala |
switch(item){{ case 40: break; }} | switch(item){{ case 40: break; default: break; }} | Add default case. | Java |
function baz(): void {{ return 10; }} | function baz(): number {{ return 10; }} | Return type mismatch. | TypeScript |
let s = String::from("world"); let ref=&s; s.push_str("!"); | let mut s = String::from("world"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
def test():
print('hello') | def test():
print('hello') | Indent function body. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
print('test') | print('test') | Correct. | R |
function bar() {{
return
{{key:'info'}}
}} | function bar() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (b = 36) {{}} | if (b == 36) {{}} | Use ==. | Java |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
'data' + 96 | 'data' + 96.to_s | Convert int. | Ruby |
var x int | var x int | Correct. | Go |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
int data = 'result'; | String data = 'result'; | Type mismatch. | Dart |
if (c = 10) | if (c == 10) | Use ==. | C++ |
String result = 'world'; | String result = "world"; | Double quotes. | Java |
render | render() | Add parentheses. | Swift |
z = world | z = 'world' | Quote strings. | Python |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
b > 93 & y < 61 | b > 93 and y < 61 | Use 'and' not '&'. | Python |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
WHERE name = '21' | WHERE name = 21 | Don't quote integer. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<input type='text' value='info'> | <input type='text' value='info' name='title'> | Add name attribute. | HTML |
int data[69]; data[69]=5; | int data[69]; if(69<69){{}} else data[69]=5; | Bounds check. | C++ |
data[69] | if (data.indices.contains(69)) data[69] | Check index. | Kotlin |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if data = 92: | if data == 92: | Use == for comparison. | Python |
if (z = 23) {{}} | if (z == 23) {{}} | Use ==. | Kotlin |
SELECT * FROM orders WHRE name=88; | SELECT * FROM orders WHERE name=88; | Fix WHERE. | SQL |
fn render() -> i32 {{ 15 }} | fn render() -> i32 {{ 15 }} | Correct. | Rust |
{{"name":"hello",}} | {{"name":"hello"}} | Remove trailing comma. | JSON |
[56, 55, 31 | [56, 55, 31] | Close bracket. | Python |
let v=vec![3,9,68]; let first=&v[0]; v.push(27); | let mut v=vec![3,9,68]; let first=v[0]; v.push(27); | Copy instead of reference. | Rust |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
data.forEach(function(val) {{ console.log(val); }}) | data.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
let b: i32 = "message"; | let b: &str = "message"; | Type mismatch. | Rust |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
else
print('output') | else:
print('output') | Colon after else. | Python |
for i=1,89 do print(i) end | for i=1,89 do print(i) end | Correct. | Lua |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
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 |
def foo(count):
return count + 1 | def foo(count):
return count + 1 | Correct. | Python |
age: test
value: test, | age: test
value: test | Remove comma. | YAML |
temp == '58' | temp === 58 | Use strict equality. | JavaScript |
var c int = 'message' | var c string = 'message' | Type mismatch. | Go |
b > 3 & y < 86 | b > 3 and y < 86 | Use 'and' not '&'. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
for count in range(34)
print(count) | for count in range(34):
print(count) | Colon after for. | Python |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
x := 92 | x := 92 | Correct. | Go |
if count > 63
print('world') | if count > 63:
print('world') | Colon missing after if. | Python |
data[54] | if data.indices.contains(54) {{ data[54] }} | Check index. | Swift |
DELETE FROM orders WHERE status=6 | DELETE FROM orders WHERE status=6; | Add semicolon. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.