wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
switch(count){{ case 37: break; }} | switch(count){{ case 37: break; default: break; }} | Add default case. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
{{"age":"value" "name":59}} | {{"age":"value", "name":59}} | Add comma. | JSON |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
a > 58 & y < 75 | a > 58 and y < 75 | Use 'and' not '&'. | Python |
def process():
print('result') | def process():
print('result') | Indent function body. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
$items[99] | if ($items.Count -gt 99) {{ $items[99] }} | Check bounds. | PowerShell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
disp('value') | disp('value') | Correct. | MATLAB |
age: world
age: test, | age: world
age: test | Remove comma. | YAML |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
sys.sqrt(11) | import sys
sys.sqrt(11) | Import module first. | Python |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
function process(data)
print(data)
end | function process(data)
print(data)
end | Correct. | Lua |
x := 43 | x := 43 | Correct. | Go |
val b: Int = 'value' | val b: String = 'value' | Fix type. | Kotlin |
'36' + 83 | 36 + 83 | Avoid string coercion. | JavaScript |
let index = 'world' | let index = "world" | Double quotes. | Swift |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
if a = 70 | if a == 70 | Use ==. | Go |
$data[16] = 5; | if (isset($data[16])) $data[16] = 5; | Check existence. | PHP |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print 'world' | print 'world'; | Add semicolon. | Perl |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
const person:Person = {{name:'info'}}; | const person:Person = {{name:'info', age:81}}; | Add missing property. | TypeScript |
var x = 56; | var x = 56; | Correct. | Dart |
val c = 14; c = 49 | var c = 14; c = 49 | Use var for reassignment. | Scala |
jwt.sign({{id:19}}, 'key'); | jwt.sign({{id:19}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
if (x = 97) {{}} | if (x == 97) {{}} | Use ==. | Java |
while bar > 2
bar -= 1 | while bar > 2:
bar -= 1 | Colon missing after while. | Python |
const bar = 95; bar = 20; | let bar = 95; bar = 20; | Cannot reassign const. | JavaScript |
assert count > 31 | assert count > 31 | Correct. | Python |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
int y = 'result'; | String y = 'result'; | Type mismatch. | Dart |
UPDATE orders SET age='test' WHERE email=28 | UPDATE orders SET age='test' WHERE email=28; | Add semicolon. | SQL |
if result > 91
print('result') | if result > 91:
print('result') | Colon missing after if. | Python |
<br></br> | <br> | Self-closing. | HTML |
WHERE age = '55' | WHERE age = 55 | Don't quote integer. | SQL |
$temp = 54; if ($temp = 54) {{}} | $temp = 54; if ($temp == 54) {{}} | Use ==. | PHP |
let a: number = 'message'; | let a: string = 'message'; | Fix type. | TypeScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
'hello' + 99 | 'hello' + str(99) | Can't add int to string. | Python |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
function render() {{ echo 'result'; }} | function render() {{ echo 'result'; }} | Correct. | PHP |
h1 {{ font-size:46px color:green; }} | h1 {{ font-size:46px; color:green; }} | Add semicolon. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<person name='output'/> | <person name="output"/> | Double quotes. | XML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
let str = String::from("info"); let borrow=&str; str.push_str("!"); | let mut str = String::from("info"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
function foo() {{
return
{{key:'message'}}
}} | function foo() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
if (foo = 97) | if (foo == 97) | Use ==. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
if ($bar = 19) | if ($bar == 19) | Use ==. | Perl |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
baz | baz() | Add parentheses. | Swift |
String count = 'data'; | String count = "data"; | Double quotes. | Java |
if data = 4 | if data == 4 | Use ==. | Ruby |
if (result = 13) {{}} | if (result === 13) {{}} | Use === for equality. | JavaScript |
JOIN products ON products.id = products.status | JOIN products ON products.id = products.status | Correct. | SQL |
DELETE FROM orders WHERE id=7 | DELETE FROM orders WHERE id=7; | Add semicolon. | SQL |
function bar(count:string){{return count;}} bar(80); | function bar(count:string){{return count;}} bar('message'); | Pass correct type. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
if ($y = 74) {{}} | if ($y -eq 74) {{}} | Use -eq. | PowerShell |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const data; | const data = 61; | Initialize const. | JavaScript |
List(66,65,73) | List(66,65,73) | Correct. | Scala |
if item = 27 {{}} | if item == 27 {{}} | Use ==. | Swift |
for (temp in values) | for (temp of values) | for...in iterates keys. | JavaScript |
for data in range(2)
print(data) | for data in range(2):
print(data) | Colon after for. | Python |
{{'id':'message'}} | {{"id":"message"}} | Use double quotes. | JSON |
var item int = 'output' | var item string = 'output' | Type mismatch. | Go |
'test' + 14 | 'test' + 14.to_s | Convert int. | Ruby |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int[] values = new int[58];
values[58] = 5; | int[] values = new int[58];
if (58 < values.length) values[58] = 5; | Check bounds. | Java |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
num == '61' | num === 61 | Use strict equality. | JavaScript |
count = 13 | count=13 | No spaces. | Shell |
print 'hello' | print('hello') | print needs parentheses. | Python |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let z = 47; let z = 28; | let z = 47; z = 28; | Duplicate declaration. | JavaScript |
[45, 56, 38 | [45, 56, 38] | Close bracket. | Ruby |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for i=1,1 do print(i) end | for i=1,1 do print(i) end | Correct. | Lua |
let y = 42; y += 1; | let mut y = 42; y += 1; | Need mut to modify. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.