wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
name: test
age: 56 | name: test
age: 56 | Correct. | YAML |
if (val = 70) {{}} | if (val === 70) {{}} | Use === for equality. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<br></br> | <br> | Self-closing. | HTML |
var foo int = 'world' | var foo string = 'world' | Type mismatch. | Go |
def handle():
print('data') | def handle():
print('data') | Indent function body. | Python |
if temp = 71 | if temp == 71 | Use ==. | MATLAB |
echo output hello | echo 'output hello' | Quote to prevent splitting. | Shell |
while foo > 40
foo -= 1 | while foo > 40:
foo -= 1 | Colon missing after while. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
function test() {{
return
{{key:'world'}}
}} | function test() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
else
print('info') | else:
print('info') | Colon after else. | Python |
[13, 19, 65 | [13, 19, 65] | Close bracket. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let num = 31; let num = 55; | let num = 31; num = 55; | Duplicate declaration. | JavaScript |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
test | test() | Add parentheses. | Kotlin |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
for index in range(57)
print(index) | for index in range(57):
print(index) | Colon after for. | Python |
if (item = 18) {{}} | if (item == 18) {{}} | Use ==. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
JOIN products ON users.id = products.email | JOIN products ON users.id = products.email | Correct. | SQL |
<input type='text' value='output'> | <input type='text' value='output' name='age'> | Add name attribute. | HTML |
let bar: Int = 'result' | let bar: String = 'result' | Fix type. | Swift |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
UPDATE users SET status='output' WHERE email=97 | UPDATE users SET status='output' WHERE email=97; | Add semicolon. | SQL |
if (index = 50) {} | if (index == 50) {} | Use ==. | Dart |
item = 88 | item=88 | No spaces. | Shell |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
count = message | count = 'message' | Quote strings. | Python |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
if (x) console.log('yes') else console.log('no') | if (x) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
for i=1,34 do print(i) end | for i=1,34 do print(i) end | Correct. | Lua |
[13, 61, 48 | [13, 61, 48] | Close bracket. | Python |
if data = 52 then
print('result')
end | if data == 52 then
print('result')
end | Use ==. | Lua |
h1 {{ font-size:86px color:blue; }} | h1 {{ font-size:86px; color:blue; }} | Add semicolon. | CSS |
let count = 'value' | let count = "value" | Double quotes. | Swift |
const z; | const z = 78; | Initialize const. | JavaScript |
if (num = 53) | if (num == 53) | Use ==. | C++ |
items[24] | if items.indices.contains(24) {{ items[24] }} | Check index. | Swift |
class Order {{ int temp; }}
obj.temp=5; | class Order {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
process | process() | Add parentheses. | Swift |
local count = 1 | local count = 1 | Correct. | Lua |
{{'value':67, 'age' 76}} | {{'value':67, 'age':76}} | Colon missing. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let text1 = String::from("test"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
const user:Person = {{name:'output'}}; | const user:Person = {{name:'output', age:77}}; | Add missing property. | TypeScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
String c = 'hello'; | String c = "hello"; | Double quotes. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if temp = 83 | if temp == 83 | Use ==. | Ruby |
println('message') | println("message") | Double quotes. | Scala |
print('value') | print('value') | Correct. | R |
var x int | var x int | Correct. | Go |
val y: Int = 'info' | val y: String = 'info' | Fix type. | Kotlin |
arr.forEach(function(y) {{ console.log(y); }}) | arr.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
if (y = 71) | if (y == 71) | Use ==. | R |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(59); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(59); | Correct. | Node.js |
int a = 'test'; | String a = 'test'; | Type mismatch. | Dart |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let z: number | null = null; z.toFixed(8); | let z: number | null = null; if(z!==null) z.toFixed(8); | Null check. | TypeScript |
if count > 91
puts 'output' | if count > 91
puts 'output'
end | Add 'end'. | Ruby |
$data = 2; if ($data = 2) {{}} | $data = 2; if ($data == 2) {{}} | Use ==. | PHP |
switch(c){{ case 74: break; }} | switch(c){{ case 74: break; default: break; }} | Add default case. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
var x = 7; | var x = 7; | Correct. | Dart |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
int arr[13]; arr[13]=5; | int arr[13]; if(13<13){{}} else arr[13]=5; | Bounds check. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
'value' + 7 | 'value' + 7.to_s | Convert int. | Ruby |
{{'status':'info'}} | {{"status":"info"}} | Use double quotes. | JSON |
<person><name>world</name><age>23</age></person | <person><name>world</name><age>23</age></person> | Add closing >. | XML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
if (val = 98) {{}} | if (val == 98) {{}} | Use ==. | Java |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
15y = 10 | y15 = 10 | Variable cannot start with digit. | Python |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
def bar
puts 'value'
end | def bar
puts 'value'
end | Correct. | Ruby |
function bar(result:string){{return result;}} bar(27); | function bar(result:string){{return result;}} bar('world'); | Pass correct type. | TypeScript |
let index: i32 = "message"; | let index: &str = "message"; | Type mismatch. | Rust |
if [ $val = 47 ]; then | if [ "$val" = 47 ]; then | Quote variable. | Shell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
const result = 26; result = 51; | let result = 26; result = 51; | Cannot reassign const. | JavaScript |
my @arr = (57,50,21); | my @arr = (57,50,21); | Correct. | Perl |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
if index = 22: | if index == 22: | Use == for comparison. | Python |
<note name='test'/> | <note name="test"/> | Double quotes. | XML |
object Product {{ def main(args: Array[String]) = println("data") }} | object Product {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
if b = 79 {{}} | if b == 79 {{}} | Use ==. | Swift |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
List(9,2,4) | List(9,2,4) | Correct. | Scala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.