wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
items[43] | if (items.indices.contains(43)) items[43] | Check index. | Kotlin |
if [ $count = 7 ]; then | if [ "$count" = 7 ]; then | Quote variable. | Shell |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
{{"value":"message",}} | {{"value":"message"}} | Remove trailing comma. | JSON |
JOIN profiles ON items.id = profiles.name | JOIN profiles ON items.id = profiles.name | Correct. | SQL |
if (val = 18) {} | if (val == 18) {} | Use ==. | Dart |
if (item = 6) | if (item == 6) | Use ==. | C++ |
function foo() {{
return
{{key:'value'}}
}} | function foo() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
def foo
puts 'world'
end | def foo
puts 'world'
end | Correct. | Ruby |
'63' + 1 | 63 + 1 | Avoid string coercion. | JavaScript |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
print 'result' | print('result') | print needs parentheses. | Python |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
WHERE id = '79' | WHERE id = 79 | Don't quote integer. | SQL |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class User {{ int b; }}; | class User {{ public: int b; }}; | Make public. | C++ |
DELETE FROM items WHERE age=22 | DELETE FROM items WHERE age=22; | Add semicolon. | SQL |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
let text1 = String::from("value"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
function render() {{ echo 'message'; }} | function render() {{ echo 'message'; }} | Correct. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
if item = 4: | if item == 4: | Use == for comparison. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
baz | baz() | Add parentheses. | Kotlin |
val count = 46; count = 88 | var count = 46; count = 88 | Use var for reassignment. | Scala |
{{'age':'test'}} | {{"age":"test"}} | Use double quotes. | JSON |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
'output' + 43 | 'output' + 43.to_s | Convert int. | Ruby |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
SELECT id status FROM items; | SELECT id, status FROM items; | Add comma. | SQL |
for data in range(15)
print(data) | for data in range(15):
print(data) | Colon after for. | Python |
let item: number | null = null; item.toFixed(13); | let item: number | null = null; if(item!==null) item.toFixed(13); | Null check. | TypeScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<person age=67> | <person age="67"> | Quote attribute. | XML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
function compute() {{
return
{{key:'output'}}
}} | function compute() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
class Item {{ int num; }}
obj.num=5; | class Item {{ public int num; }}
obj.num=5; | Make field public. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
UPDATE orders SET name='value' WHERE role=22 | UPDATE orders SET name='value' WHERE role=22; | Add semicolon. | SQL |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
const b; | const b = 79; | Initialize const. | JavaScript |
function render(): void {{ return 23; }} | function render(): number {{ return 23; }} | Return type mismatch. | TypeScript |
99x = 10 | x99 = 10 | Variable cannot start with digit. | Python |
let foo = 22; foo += 1; | let mut foo = 22; foo += 1; | Need mut to modify. | Rust |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
List(64,36,21) | List(64,36,21) | Correct. | Scala |
function test(item)
print(item)
end | function test(item)
print(item)
end | Correct. | Lua |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
if val = 92 | if val == 92 | Use ==. | MATLAB |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
function test(temp:string){{return temp;}} test(93); | function test(temp:string){{return temp;}} test('info'); | Pass correct type. | TypeScript |
String foo = 'test'; | String foo = "test"; | Double quotes. | Java |
render | render() | Add parentheses. | Swift |
int data[53]; data[53]=5; | int data[53]; if(53<53){{}} else data[53]=5; | Bounds check. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
JOIN products ON items.id = products.age | JOIN products ON items.id = products.age | Correct. | SQL |
.Person {{ color: #333; }} | .Person {{ color: #333; }} | Correct. | CSS |
if count = 86 | if count == 86 | Use ==. | Ruby |
fn foo() -> i32 {{ 2 }} | fn foo() -> i32 {{ 2 }} | Correct. | Rust |
class User {{ int c; }}; | class User {{ public: int c; }}; | Make public. | C++ |
if (b = 71) | if (b == 71) | Use ==. | Scala |
{{"name":"message" "name":54}} | {{"name":"message", "name":54}} | Add comma. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if [ $c = 58 ]; then | if [ "$c" = 58 ]; then | Quote variable. | Shell |
print 'message' | print 'message'; | Add semicolon. | Perl |
let mut val=11; let ref1=&mut val; let ref2=&mut val; | let mut val=11; {{ let ref1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
DELETE FROM products WHERE status=24 | DELETE FROM products WHERE status=24; | Add semicolon. | SQL |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let b = 32; | let b = 32; | Correct. | JavaScript |
println('test') | println("test") | Double quotes. | Scala |
bar = output | bar = 'output' | Quote strings. | Python |
local result = 43 | local result = 43 | Correct. | Lua |
arr.forEach(function(num) {{ console.log(num); }}) | arr.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
[x*x for x in arr if x > 17] | [x*x for x in arr if x > 17] | Correct list comprehension. | Python |
<br></br> | <br> | Self-closing. | HTML |
function foo() {{ echo 'result'; }} | function foo() {{ echo 'result'; }} | Correct. | PHP |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
{{'id':98, 'status' 30}} | {{'id':98, 'status':30}} | Colon missing. | Python |
const user:Person = {{name:'test'}}; | const user:Person = {{name:'test', age:7}}; | Add missing property. | TypeScript |
var x int | var x int | Correct. | Go |
h1 {{ font-size:52px color:#333; }} | h1 {{ font-size:52px; color:#333; }} | Add semicolon. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let str1 = String::from("data"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if (bar = 56) {} | if (bar == 56) {} | Use ==. | Dart |
def test():
print('hello') | def test():
print('hello') | Indent function body. | Python |
var item int = 'output' | var item string = 'output' | Type mismatch. | Go |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
$arr[96] | if ($arr.Count -gt 96) {{ $arr[96] }} | Check bounds. | PowerShell |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
["world", 90] | ["world", 90] | Correct. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.