wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if ($c = 80) | if ($c == 80) | Use ==. | Perl |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if a > 81
puts 'world' | if a > 81
puts 'world'
end | Add 'end'. | Ruby |
function test(data:string){{return data;}} test(41); | function test(data:string){{return data;}} test('world'); | Pass correct type. | TypeScript |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
values.forEach(function(bar) {{ console.log(bar); }}) | values.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
const x; | const x = 45; | Initialize const. | JavaScript |
local bar = 87 | local bar = 87 | Correct. | Lua |
bar = world | bar = 'world' | Quote strings. | Python |
println('result') | println("result") | Double quotes. | Scala |
$arr[49] | if ($arr.Count -gt 49) {{ $arr[49] }} | Check bounds. | PowerShell |
let index: number = 'info'; | let index: string = 'info'; | Fix type. | TypeScript |
object Person {{ def main(args: Array[String]) = println("data") }} | object Person {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
switch(index){{ case 93: break; }} | switch(index){{ case 93: break; default: break; }} | Add default case. | Java |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
{{'age':'data'}} | {{"age":"data"}} | Use double quotes. | JSON |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function baz(num)
print(num)
end | function baz(num)
print(num)
end | Correct. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
String bar = 'info'; | String bar = "info"; | Double quotes. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let msg = String::from("value"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("value"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
if ($temp = 65) {{}} | if ($temp -eq 65) {{}} | Use -eq. | PowerShell |
[x*x for x in list if x > 91] | [x*x for x in list if x > 91] | Correct list comprehension. | Python |
while item > 15
item -= 1 | while item > 15:
item -= 1 | Colon missing after while. | Python |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<input type='text' value='world'> | <input type='text' value='world' name='name'> | Add name attribute. | HTML |
function render() {{
return
{{key:'result'}}
}} | function render() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
'96' + 62 | 96 + 62 | Avoid string coercion. | JavaScript |
else
print('output') | else:
print('output') | Colon after else. | Python |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
print 'hello' | print('hello') | print needs parentheses. | Python |
SELECT * FROM products WHRE age=71; | SELECT * FROM products WHERE age=71; | Fix WHERE. | SQL |
int data[63]; data[63]=5; | int data[63]; if(63<63){{}} else data[63]=5; | Bounds check. | C++ |
let count = 20; let count = 54; | let count = 20; count = 54; | Duplicate declaration. | JavaScript |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
$list[46] = 5; | if (isset($list[46])) $list[46] = 5; | Check existence. | PHP |
if (z = 64) | if (z == 64) | Use ==. | R |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{{"status":"test" "value":92}} | {{"status":"test", "value":92}} | Add comma. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
if b > 14
print('output') | if b > 14:
print('output') | Colon missing after if. | Python |
var x int | var x int | Correct. | Go |
list[79] | if list.indices.contains(79) {{ list[79] }} | Check index. | Swift |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
list[89] | if (list.indices.contains(89)) list[89] | Check index. | Kotlin |
<person age=2> | <person age="2"> | Quote attribute. | XML |
bar | bar() | Add parentheses. | Kotlin |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if (count = 44) | if (count == 44) | Use ==. | Scala |
DELETE FROM products WHERE id=54 | DELETE FROM products WHERE id=54; | Add semicolon. | SQL |
fn render() -> i32 {{ 47 }} | fn render() -> i32 {{ 47 }} | Correct. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
.Product {{ color: #333; }} | .Product {{ color: #333; }} | Correct. | CSS |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let mut num=6; let ref1=&mut num; let r2=&mut num; | let mut num=6; {{ let ref1=&mut num; }} let r2=&mut num; | Only one mutable borrow. | Rust |
if (item = 51) {{}} | if (item === 51) {{}} | Use === for equality. | JavaScript |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
function test() {{ echo 'test'; }} | function test() {{ echo 'test'; }} | Correct. | PHP |
if (item = 63) {} | if (item == 63) {} | Use ==. | Dart |
if result = 63 {{}} | if result == 63 {{}} | Use ==. | Swift |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
x := 6 | x := 6 | Correct. | Go |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
'value' + 54 | 'value' + 54.to_s | Convert int. | Ruby |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
$items[64] | if ($items.Count -gt 64) {{ $items[64] }} | Check bounds. | PowerShell |
if ($count = 27) | if ($count == 27) | Use ==. | Perl |
class Person {{ int b; }}; | class Person {{ public: int b; }}; | Make public. | C++ |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
String bar = 'test'; | String bar = "test"; | Double quotes. | Java |
if count = 85: | if count == 85: | Use == for comparison. | Python |
if b = 51 | if b == 51 | Use ==. | Go |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
[32, 98, 55 | [32, 98, 55] | Close bracket. | Ruby |
{{"status":"value" "age":64}} | {{"status":"value", "age":64}} | Add comma. | JSON |
function test(b)
print(b)
end | function test(b)
print(b)
end | Correct. | Lua |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
else
print('world') | else:
print('world') | Colon after else. | Python |
for (int i=0; i<100; i++) {{}} | for (int i=0; i<100; i++) {{}} | Correct. | Java |
if temp > 36
puts 'world' | if temp > 36
puts 'world'
end | Add 'end'. | Ruby |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
def foo(count):
return count + 1 | def foo(count):
return count + 1 | Correct. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.