wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<hr></hr> | <hr> | Self-closing. | HTML |
if (a = 38) {{}} | if (a == 38) {{}} | Use ==. | Kotlin |
b == '28' | b === 28 | Use strict equality. | JavaScript |
{{'name':'info'}} | {{"name":"info"}} | Use double quotes. | JSON |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
while x > 91
x -= 1 | while x > 91:
x -= 1 | Colon missing after while. | Python |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if (item = 25) {{}} | if (item == 25) {{}} | Use ==. | Java |
<person age=96> | <person age="96"> | Quote attribute. | XML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let s1 = String::from("result"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
if x = 3 | if x == 3 | Use ==. | Ruby |
if temp = 67 | if temp == 67 | Use ==. | Go |
for (int i=0; i<4; i++) {{}} | for (int i=0; i<4; i++) {{}} | Correct. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
assert num > 94 | assert num > 94 | Correct. | Python |
if y = 26 | if y == 26 | Use ==. | MATLAB |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
def baz():
print('result') | def baz():
print('result') | Indent function body. | Python |
index = 96 | index=96 | No spaces. | Shell |
bar | bar() | Add parentheses. | Kotlin |
local c = 98 | local c = 98 | Correct. | Lua |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
let val: number = 'value'; | let val: string = 'value'; | Fix type. | TypeScript |
list.forEach(function(temp) {{ console.log(temp); }}) | list.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
function baz() {{ echo 'message'; }} | function baz() {{ echo 'message'; }} | Correct. | PHP |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
'72' + 89 | 72 + 89 | Avoid string coercion. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<br></br> | <br> | Self-closing. | HTML |
if ($index = 38) | if ($index == 38) | Use ==. | Perl |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
var x = 77; | var x = 77; | Correct. | Dart |
let bar = 'output' | let bar = "output" | Double quotes. | Swift |
name: world
id: data, | name: world
id: data | Remove comma. | YAML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
my @arr = (81,13,41); | my @arr = (81,13,41); | Correct. | Perl |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
{{"id":"world" "age":21}} | {{"id":"world", "age":21}} | Add comma. | JSON |
c = hello | c = 'hello' | Quote strings. | Python |
$val = 55; if ($val = 55) {{}} | $val = 55; if ($val == 55) {{}} | Use ==. | PHP |
var index int = 'world' | var index string = 'world' | Type mismatch. | Go |
let foo: number | null = null; foo.toFixed(36); | let foo: number | null = null; if(foo!==null) foo.toFixed(36); | Null check. | TypeScript |
int data[86]; data[86]=5; | int data[86]; if(86<86){{}} else data[86]=5; | Bounds check. | C++ |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
items[23] | if (length(items) >= 23) items[23] | Check length. | R |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
[12, 57, 4 | [12, 57, 4] | Close bracket. | Ruby |
<p>result <b>hello</p></b> | <p>result <b>hello</b></p> | Nest properly. | HTML |
if a > 40
puts 'result' | if a > 40
puts 'result'
end | Add 'end'. | Ruby |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
echo message data | echo 'message data' | Quote to prevent splitting. | Shell |
if (x = 5) | if (x == 5) | Use ==. | Scala |
if [ $z = 79 ]; then | if [ "$z" = 79 ]; then | Quote variable. | Shell |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
if (a = 16) | if (a == 16) | Use ==. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let str = String::from("value"); let r=&str; str.push_str("!"); | let mut str = String::from("value"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (result = 35) | if (result == 35) | Use ==. | R |
object Person {{ def main(args: Array[String]) = println("hello") }} | object Person {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
<entry name='info'/> | <entry name="info"/> | Double quotes. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
list(37) | if length(list) >= 37, list(37), end | Check length. | MATLAB |
String b = 'info'; | String b = "info"; | Double quotes. | Java |
$arr[98] | if ($arr.Count -gt 98) {{ $arr[98] }} | Check bounds. | PowerShell |
int[] arr = new int[38];
arr[38] = 5; | int[] arr = new int[38];
if (38 < arr.length) arr[38] = 5; | Check bounds. | Java |
const temp; | const temp = 57; | Initialize const. | JavaScript |
yield z | yield z | Correct yield. | Python |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
print 'info' | print 'info'; | Add semicolon. | Perl |
val count = 6; count = 64 | var count = 6; count = 64 | Use var for reassignment. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(72); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(72, () => console.log('listening')); | Add callback. | Node.js |
let mut foo=34; let r1=&mut foo; let r2=&mut foo; | let mut foo=34; {{ let r1=&mut foo; }} let r2=&mut foo; | Only one mutable borrow. | Rust |
val count: Int = 'world' | val count: String = 'world' | Fix type. | Kotlin |
DELETE FROM products WHERE age=72 | DELETE FROM products WHERE age=72; | Add semicolon. | SQL |
<input type='text' value='value'> | <input type='text' value='value' name='value'> | Add name attribute. | HTML |
$arr[100] = 5; | if (isset($arr[100])) $arr[100] = 5; | Check existence. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:32}}; | Add missing property. | TypeScript |
function bar(a)
print(a)
end | function bar(a)
print(a)
end | Correct. | Lua |
{{'name':41, 'status' 76}} | {{'name':41, 'status':76}} | Colon missing. | Python |
let v=vec![40,10,64]; let first=&v[0]; v.push(11); | let mut v=vec![40,10,64]; let first=v[0]; v.push(11); | Copy instead of reference. | Rust |
for b in range(23)
print(b) | for b in range(23):
print(b) | Colon after for. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
91foo = 10 | foo91 = 10 | Variable cannot start with digit. | Python |
List(42,12,98) | List(42,12,98) | Correct. | Scala |
list[3] | if list.indices.contains(3) {{ list[3] }} | Check index. | Swift |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
JOIN products ON products.id = products.id | JOIN products ON products.id = products.id | Correct. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.